def upload_files_to_job_batch()

in src/wagtail_localize_smartling/api/client.py [0:0]


    def upload_files_to_job_batch(self, *, job: "Job", batch_uid: str) -> str:
        file_uri = self.get_file_uri_for_job(job=job)

        locales_to_authorize = [
            utils.format_smartling_locale_id(t.target_locale.language_code)
            for t in job.translations.all()
        ]

        data_payload = {
            # NB: If we switch to multiple files per Batch (e.g. different
            # locales per upload to the batch, for some reason), the fileUri must
            # be unique _per Batch_. With a single file, it's not a concern.
            "fileUri": file_uri,
            "fileType": "gettext",
            "localeIdsToAuthorize[]": locales_to_authorize,
        }

        file_payload = {
            "file": (file_uri, str(job.translation_source.export_po())),
        }

        self._request(
            method="POST",
            path=f"/job-batches-api/v2/projects/{quote(job.project.project_id)}/batches/{batch_uid}/file",
            response_serializer_class=UploadFileToBatchResponseSerializer,
            files=file_payload,
            data=data_payload,
        )
        return file_uri