diff --git a/dev/build_doc_json_responses/README.md b/dev/build_doc_json_responses/README.md index edfd94ef..aa070d62 100644 --- a/dev/build_doc_json_responses/README.md +++ b/dev/build_doc_json_responses/README.md @@ -9,21 +9,21 @@ NOTE: The test names are VERY important and must match up with the expected plur ## Installation ```bash -make install +just install ``` ## Usage First, if you are regenerating response snippets, you will first need to delete the related cassette file(s) in `tests/cassettes`. If a cassette file already exists for a given snippet, it will not be overwritten and the generated response snippet will not be updated. -Next, you will need to run the `make generate` command twice - it will fail the first time through; this is expected. +Next, you will need to run the `just generate` command twice - it will fail the first time through; this is expected. ```bash # Run the following to save HTTP recordings -EASYPOST_TEST_API_KEY=putrealkeyhere EASYPOST_PROD_API_KEY=putrealkeyhere PARTNER_USER_PROD_API_KEY=putrealkeyhere REFERRAL_CUSTOMER_PROD_API_KEY=putrealkeyhere make generate +EASYPOST_TEST_API_KEY=putrealkeyhere EASYPOST_PROD_API_KEY=putrealkeyhere PARTNER_USER_PROD_API_KEY=putrealkeyhere REFERRAL_CUSTOMER_PROD_API_KEY=putrealkeyhere just generate # Run the same command again to save the response snippets -EASYPOST_TEST_API_KEY=putrealkeyhere EASYPOST_PROD_API_KEY=putrealkeyhere PARTNER_USER_PROD_API_KEY=putrealkeyhere REFERRAL_CUSTOMER_PROD_API_KEY=putrealkeyhere make generate +EASYPOST_TEST_API_KEY=putrealkeyhere EASYPOST_PROD_API_KEY=putrealkeyhere PARTNER_USER_PROD_API_KEY=putrealkeyhere REFERRAL_CUSTOMER_PROD_API_KEY=putrealkeyhere just generate ``` **NOTE**: Some static data used by this tool, such as the USPS carrier account ID, is associated with the EasyPost Docs Tooling User. You must use that user's API keys to generate these snippets. @@ -34,9 +34,9 @@ Generated response snippets are stored in the `responses` directory. Copy this e ## Linting -The `make lint` and `make lint-fix` commands in the Makefile will lint the Python code in this tool, but not the response snippets. +The `just lint` and `just lint-fix` commands in the Makefile will lint the Python code in this tool, but not the response snippets. -After copying the response snippets to `docs/responses`, you can lint them with the `make format-node` command in the root Makefile, which will lint and format all JSON files, including the response snippets, in the `docs` directory. +After copying the response snippets to `docs/responses`, you can lint them with the `just format-node` command in the root Makefile, which will lint and format all JSON files, including the response snippets, in the `docs` directory. ## Troubleshooting diff --git a/dev/build_doc_json_responses/builder/snippets.py b/dev/build_doc_json_responses/builder/snippets.py index 8b4c35b6..60e224a6 100644 --- a/dev/build_doc_json_responses/builder/snippets.py +++ b/dev/build_doc_json_responses/builder/snippets.py @@ -127,15 +127,25 @@ def save_response_snippet( """Saves the response content of a cassette to a standalone snippet file.""" response_snippet_folder, bare_snippet_name = _setup_saving_response_snippet(response_snippet_filename) - with open(os.path.join(RESPONSES_DIR, response_snippet_folder, bare_snippet_name), "w") as response_snippet_file: + with open( + os.path.join(RESPONSES_DIR, response_snippet_folder, bare_snippet_name), + "w", + encoding="utf-8", + ) as response_snippet_file: if objects_to_persist: json.dump( json.loads(response_snippet_content)[:objects_to_persist], response_snippet_file, indent=2, + ensure_ascii=False, # It's possible we have non-ASCII characters in the response that we want preserved ) else: - json.dump(json.loads(response_snippet_content), response_snippet_file, indent=2) + json.dump( + json.loads(response_snippet_content), + response_snippet_file, + indent=2, + ensure_ascii=False, # It's possible we have non-ASCII characters in the response that we want preserved + ) response_snippet_file.write("\n") @@ -148,7 +158,16 @@ def save_raw_json(response_snippet_filename: str, response_dict: dict[str, Any]) """ response_snippet_folder, bare_snippet_name = _setup_saving_response_snippet(response_snippet_filename) - with open(os.path.join(RESPONSES_DIR, response_snippet_folder, bare_snippet_name), "w") as response_snippet_file: - json.dump(response_dict, response_snippet_file, indent=2) + with open( + os.path.join(RESPONSES_DIR, response_snippet_folder, bare_snippet_name), + "w", + encoding="utf-8", + ) as response_snippet_file: + json.dump( + response_dict, + response_snippet_file, + indent=2, + ensure_ascii=False, # It's possible we have non-ASCII characters in the response that we want preserved + ) response_snippet_file.write("\n") diff --git a/docs/responses/carrier-metadata/retrieve.json b/docs/responses/carrier-metadata/retrieve.json index ad534136..08fa57a8 100644 --- a/docs/responses/carrier-metadata/retrieve.json +++ b/docs/responses/carrier-metadata/retrieve.json @@ -1,7 +1,7 @@ { "carriers": [ { - "human_readable": "USPS", + "human_readable": "USPS BYOCA", "name": "usps", "predefined_packages": [ { @@ -205,7 +205,7 @@ "Cards, Letters and Flats only (no Parcels)", "See Predefined Packages (Card, Letter, Flat) for details" ], - "human_readable": "First-Class Mail\u00ae", + "human_readable": "First-Class Mail®", "max_weight": 13.0, "name": "First" }, @@ -215,7 +215,7 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Priority Mail\u00ae", + "human_readable": "Priority Mail®", "max_weight": 1120.0, "name": "Priority" }, @@ -225,7 +225,7 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Priority Mail Express\u00ae", + "human_readable": "Priority Mail Express®", "max_weight": 1120.0, "name": "Express" }, @@ -235,8 +235,8 @@ "dimensions": [ "Combined Length and Girth < 130in" ], - "human_readable": "USPS Ground Advantage\u00ae", - "max_weight": 70.0, + "human_readable": "USPS Ground Advantage®", + "max_weight": 1120.0, "name": "GroundAdvantage" }, { @@ -245,7 +245,7 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Library Mail\u00ae", + "human_readable": "Library Mail®", "max_weight": 1120.0, "name": "LibraryMail" }, @@ -255,7 +255,7 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Media Mail\u00ae", + "human_readable": "Media Mail®", "max_weight": 1120.0, "name": "MediaMail" }, @@ -265,7 +265,7 @@ "dimensions": [ "Must be rectangular, otherwise an additional charge may apply." ], - "human_readable": "First-Class Mail International\u00ae", + "human_readable": "First-Class Mail International®", "max_weight": 15.994, "name": "FirstClassMailInternational" }, @@ -277,7 +277,7 @@ "Rolls (Tubes): Length: min 4in; max 36 in. Length plus twice the diameter (combined): min 6.75 in; max 42in.", "Some countries have specific prohibitions and restrictions" ], - "human_readable": "First-Class Package International Service\u00ae", + "human_readable": "First-Class Package International Service®", "max_weight": 64.0, "name": "FirstClassPackageInternationalService" }, @@ -287,7 +287,7 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Priority Mail International\u00ae", + "human_readable": "Priority Mail International®", "max_weight": 1120.0, "name": "PriorityMailInternational" }, @@ -297,11 +297,12 @@ "dimensions": [ "Combined Length and Girth < 108in" ], - "human_readable": "Priority Mail Express International\u00ae", + "human_readable": "Priority Mail Express International®", "max_weight": 1120.0, "name": "ExpressMailInternational" } - ] + ], + "type": "UspsAccount" } ] }