Name | b2cloud JSON |
Version |
0.2.0
JSON |
| download |
home_page | https://www.interman.jp/ |
Summary | ヤマト運輸株式会社が提供する送り状発行システムB2クラウドをpythonで利用するパッケージ |
upload_time | 2023-09-07 07:29:05 |
maintainer | |
docs_url | None |
author | hgs-interman |
requires_python | >=3.9,<4.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# b2cloud
ヤマト運輸株式会社の『送り状発行システムB2クラウド』を操作して伝票を印刷するためのモジュールです。
利用にあたっては、ヤマトビジネスメンバーズのaccount情報が必要となります。
## インストール
```shell
pip install b2cloud
```
## コード例
### 履歴の取得
```python
import b2cloud
import b2cloud.utilities
session = b2cloud.login('your customer_code', 'your customer_password')
dm = b2cloud.search_history(session, service_type='3')
for entry in dm['feed']['entry']:
print(entry['shipment']['tracking_number'], entry['shipment']['consignee_name'])
```
### 新規に伝票を作成し、データに不備がないかチェックする
```python
# 伝票情報を生成する
shipment = b2cloud.utilities.create_dm_shipment(
shipment_date='2022/12/24',
consignee_telephone_display='00-0000-0000',
consignee_name='テスト',
consignee_zip_code='8900053',
consignee_address1='鹿児島県',
consignee_address2='鹿児島市',
consignee_address3='中央町10',
consignee_address4='キャンセビル6階',
consignee_department1='インターマン株式会社'
)
# データに不備がないかチェックする
res = b2cloud.check_shipment(session, shipment)
print(res)
e.g.
{'success': True, 'errors': []}
```
### 伝票の新規保存
```python
# shipmentsをpost_new_checkonlyを通す
checked_feed = b2cloud.post_new_checkonly(session, [shipment])
# 伝票情報をB2クラウドに保存する
res = b2cloud.post_new(session, checked_feed)
```
### 保存した伝票をDM形式で印刷し各伝票毎にPDFファイルに保存する
```python
# 保存済みのDM伝票を取得
dm_feed = b2cloud.get_new(session, params={'service_type':'3'})
# DM伝票形式(1シート8枚)で印刷
dm_pdf = b2cloud.print_issue(session,'3', dm_feed)
# 1伝票毎に分割する
pdfs = b2cloud.utilities.split_pdf_dm(dm_pdf)
for i in range(len(pdfs)):
with open(f'dm_{i}.pdf', 'wb') as f:
f.write(pdfs[i])
```
### 住所を伝票情報に変換する
住所正規化サービスAddressian([https://addressian.netlify.app/](https://addressian.netlify.app/))のAPI Keyが必要です。
```python
consignee_address = b2cloud.utilities.get_address_info(
session=session,
addressian_api_key='abcdefghijklmnopqrtsuvwxyz1234567890',
address='鹿児島市中央町10キャンセビル6F'
)
print(consignee_address)
e.g.
{
"consignee_zip_code": "8900053",
"consignee_address1": "鹿児島県",
"consignee_address2": "鹿児島市",
"consignee_address3": "中央町10",
"consignee_address4": "キャンセビル6F"
}
```
## pytest
パラメータでログイン情報やaddressian_api_keyを指定します。
※注意
テストを実行するとテスト伝票が発行されます。
テスト実行後は、B2クラウドWEBサイトにログインして「保存分の発行」や「発行済みデータの検索」からテストデータを削除することをお勧めします。
### pytest コマンド例
```shell
pytest -q tests/test_01.py --customer_code=0123456789 --customer_password=abcdefghi --addressian_api_key=abcdefghijklmnopqrtsuvwxyz1234567890
```
### パラメーターの一覧
```python
parser.addoption("--customer_code", action="store", default="")
parser.addoption("--customer_password", action="store", default="")
parser.addoption("--customer_cls_cocde", action="store", default="")
parser.addoption("--login_user_id", action="store", default="")
parser.addoption("--addressian_api_key", action="store", default="")
```
Raw data
{
"_id": null,
"home_page": "https://www.interman.jp/",
"name": "b2cloud",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "hgs-interman",
"author_email": "naofumi.higashikawauchi@interman.co.jp",
"download_url": "https://files.pythonhosted.org/packages/02/ed/b2f5df4c977d8e62fa1563451de561b3a33d983a085ca5cf55a9ee95bd20/b2cloud-0.2.0.tar.gz",
"platform": null,
"description": "# b2cloud\n\n\u30e4\u30de\u30c8\u904b\u8f38\u682a\u5f0f\u4f1a\u793e\u306e\u300e\u9001\u308a\u72b6\u767a\u884c\u30b7\u30b9\u30c6\u30e0B2\u30af\u30e9\u30a6\u30c9\u300f\u3092\u64cd\u4f5c\u3057\u3066\u4f1d\u7968\u3092\u5370\u5237\u3059\u308b\u305f\u3081\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002\n\u5229\u7528\u306b\u3042\u305f\u3063\u3066\u306f\u3001\u30e4\u30de\u30c8\u30d3\u30b8\u30cd\u30b9\u30e1\u30f3\u30d0\u30fc\u30ba\u306eaccount\u60c5\u5831\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002\n\n## \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\n```shell\npip install b2cloud\n```\n\n## \u30b3\u30fc\u30c9\u4f8b\n\n### \u5c65\u6b74\u306e\u53d6\u5f97\n\n```python\nimport b2cloud\nimport b2cloud.utilities\n\nsession = b2cloud.login('your customer_code', 'your customer_password')\ndm = b2cloud.search_history(session, service_type='3')\n\nfor entry in dm['feed']['entry']:\n print(entry['shipment']['tracking_number'], entry['shipment']['consignee_name'])\n```\n\n### \u65b0\u898f\u306b\u4f1d\u7968\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u306b\u4e0d\u5099\u304c\u306a\u3044\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\n\n```python\n# \u4f1d\u7968\u60c5\u5831\u3092\u751f\u6210\u3059\u308b\nshipment = b2cloud.utilities.create_dm_shipment(\n shipment_date='2022/12/24',\n consignee_telephone_display='00-0000-0000',\n consignee_name='\u30c6\u30b9\u30c8',\n consignee_zip_code='8900053',\n consignee_address1='\u9e7f\u5150\u5cf6\u770c',\n consignee_address2='\u9e7f\u5150\u5cf6\u5e02',\n consignee_address3='\u4e2d\u592e\u753a10',\n consignee_address4='\u30ad\u30e3\u30f3\u30bb\u30d3\u30eb\uff16\u968e',\n consignee_department1='\u30a4\u30f3\u30bf\u30fc\u30de\u30f3\u682a\u5f0f\u4f1a\u793e'\n)\n\n# \u30c7\u30fc\u30bf\u306b\u4e0d\u5099\u304c\u306a\u3044\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\nres = b2cloud.check_shipment(session, shipment)\nprint(res)\n\ne.g.\n{'success': True, 'errors': []}\n```\n\n### \u4f1d\u7968\u306e\u65b0\u898f\u4fdd\u5b58\n\n```python\n# shipments\u3092post_new_checkonly\u3092\u901a\u3059\nchecked_feed = b2cloud.post_new_checkonly(session, [shipment])\n# \u4f1d\u7968\u60c5\u5831\u3092B2\u30af\u30e9\u30a6\u30c9\u306b\u4fdd\u5b58\u3059\u308b\nres = b2cloud.post_new(session, checked_feed)\n```\n\n### \u4fdd\u5b58\u3057\u305f\u4f1d\u7968\u3092DM\u5f62\u5f0f\u3067\u5370\u5237\u3057\u5404\u4f1d\u7968\u6bce\u306bPDF\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3059\u308b\n\n```python\n# \u4fdd\u5b58\u6e08\u307f\u306eDM\u4f1d\u7968\u3092\u53d6\u5f97\ndm_feed = b2cloud.get_new(session, params={'service_type':'3'})\n# DM\u4f1d\u7968\u5f62\u5f0f\uff08\uff11\u30b7\u30fc\u30c88\u679a\uff09\u3067\u5370\u5237\ndm_pdf = b2cloud.print_issue(session,'3', dm_feed)\n# \uff11\u4f1d\u7968\u6bce\u306b\u5206\u5272\u3059\u308b\npdfs = b2cloud.utilities.split_pdf_dm(dm_pdf)\nfor i in range(len(pdfs)):\n with open(f'dm_{i}.pdf', 'wb') as f:\n f.write(pdfs[i])\n```\n\n### \u4f4f\u6240\u3092\u4f1d\u7968\u60c5\u5831\u306b\u5909\u63db\u3059\u308b\n\n\u4f4f\u6240\u6b63\u898f\u5316\u30b5\u30fc\u30d3\u30b9Addressian([https://addressian.netlify.app/](https://addressian.netlify.app/))\u306eAPI Key\u304c\u5fc5\u8981\u3067\u3059\u3002\n\n```python\nconsignee_address = b2cloud.utilities.get_address_info(\n session=session,\n addressian_api_key='abcdefghijklmnopqrtsuvwxyz1234567890',\n address='\u9e7f\u5150\u5cf6\u5e02\u4e2d\u592e\u753a10\u30ad\u30e3\u30f3\u30bb\u30d3\u30eb6F'\n )\nprint(consignee_address)\n\ne.g.\n{\n \"consignee_zip_code\": \"8900053\",\n \"consignee_address1\": \"\u9e7f\u5150\u5cf6\u770c\",\n \"consignee_address2\": \"\u9e7f\u5150\u5cf6\u5e02\",\n \"consignee_address3\": \"\u4e2d\u592e\u753a10\",\n \"consignee_address4\": \"\u30ad\u30e3\u30f3\u30bb\u30d3\u30eb6F\"\n}\n```\n\n## pytest\n\n\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\u3084addressian_api_key\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\n\n\u203b\u6ce8\u610f\n\n\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u30c6\u30b9\u30c8\u4f1d\u7968\u304c\u767a\u884c\u3055\u308c\u307e\u3059\u3002\n\u30c6\u30b9\u30c8\u5b9f\u884c\u5f8c\u306f\u3001B2\u30af\u30e9\u30a6\u30c9WEB\u30b5\u30a4\u30c8\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u300c\u4fdd\u5b58\u5206\u306e\u767a\u884c\u300d\u3084\u300c\u767a\u884c\u6e08\u307f\u30c7\u30fc\u30bf\u306e\u691c\u7d22\u300d\u304b\u3089\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\u3002\n\n### pytest \u30b3\u30de\u30f3\u30c9\u4f8b\n\n```shell\npytest -q tests/test_01.py --customer_code=0123456789 --customer_password=abcdefghi --addressian_api_key=abcdefghijklmnopqrtsuvwxyz1234567890\n```\n\n### \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u4e00\u89a7\n\n```python\nparser.addoption(\"--customer_code\", action=\"store\", default=\"\")\nparser.addoption(\"--customer_password\", action=\"store\", default=\"\")\nparser.addoption(\"--customer_cls_cocde\", action=\"store\", default=\"\")\nparser.addoption(\"--login_user_id\", action=\"store\", default=\"\")\nparser.addoption(\"--addressian_api_key\", action=\"store\", default=\"\")\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u30e4\u30de\u30c8\u904b\u8f38\u682a\u5f0f\u4f1a\u793e\u304c\u63d0\u4f9b\u3059\u308b\u9001\u308a\u72b6\u767a\u884c\u30b7\u30b9\u30c6\u30e0B2\u30af\u30e9\u30a6\u30c9\u3092python\u3067\u5229\u7528\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://github.com/interman-corp/b2cloud",
"Homepage": "https://www.interman.jp/",
"Repository": "https://github.com/interman-corp/b2cloud"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "21ac445484af956d216cee51d986c613fc5985f7f6eb45232016ef2f23da55e0",
"md5": "ed80b063e42c9064849fc0a90cd765af",
"sha256": "11350915f567288b970faa70ea34da63daed8f4300ad2901687bffa551fa89e2"
},
"downloads": -1,
"filename": "b2cloud-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed80b063e42c9064849fc0a90cd765af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 12152,
"upload_time": "2023-09-07T07:29:03",
"upload_time_iso_8601": "2023-09-07T07:29:03.567253Z",
"url": "https://files.pythonhosted.org/packages/21/ac/445484af956d216cee51d986c613fc5985f7f6eb45232016ef2f23da55e0/b2cloud-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "02edb2f5df4c977d8e62fa1563451de561b3a33d983a085ca5cf55a9ee95bd20",
"md5": "1a51c0c2bf152b9a842b3dc28cd4bb4f",
"sha256": "99eb0152a034f7c3b8c65222385c981fb3a777b373b3be38b7dc32c6cf4e517b"
},
"downloads": -1,
"filename": "b2cloud-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "1a51c0c2bf152b9a842b3dc28cd4bb4f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 12052,
"upload_time": "2023-09-07T07:29:05",
"upload_time_iso_8601": "2023-09-07T07:29:05.252791Z",
"url": "https://files.pythonhosted.org/packages/02/ed/b2f5df4c977d8e62fa1563451de561b3a33d983a085ca5cf55a9ee95bd20/b2cloud-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-07 07:29:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "interman-corp",
"github_project": "b2cloud",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "b2cloud"
}