ne_api 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16edd23e29a39103e8ec306e6b818b42a1688aad42e5d542e3d4db3b3b79c925
4
- data.tar.gz: 3ed47af90711932cfd42ebd9a5253a0753f2d35a2d0badad04fad34fa7a4072d
3
+ metadata.gz: 6474b8bf6ff50eacf03ce97f30ee79275d2a239f21bcf7f0abce82b5c86d26e7
4
+ data.tar.gz: b81e71c968a5e36ecfffa2b45263ecc2def76c1250fc9136e7eb43c3456e0526
5
5
  SHA512:
6
- metadata.gz: e5f8c4195d02c0c4b70ef4fd5751c51de67cde63867a130f168ff4ca98726f9f57d4fc2e2eb3bc647ab88f92fb7a55b4d193dfa905dae863195d096e4a8a1216
7
- data.tar.gz: 3ae39d8ab93891d07a93f51b39bf8198ecafaaf3a723bc4aa880477f690f9982b7674a7343f4acc50a146c6db88b7330bc6237a4bd7bf0de2e9d6ca5085d343b
6
+ metadata.gz: e607e19e050b177d3263d7edd3fb7e3aacb145eb58ed761c54f5369074d9357b1fd9b9191dc20899adb797eb7d21c394cea1dd7c70032d0ca11f560f9dc6ce73
7
+ data.tar.gz: 133ec5ee2121bfd9d8791c5a3f463937739eb1f8fe42881aec2929216c86cc829bb20d7075a8e45193503db3b95daf55ea59653330324f3b5dd9a0d2d6dea465
data/BUNDLING_API.md ADDED
@@ -0,0 +1,54 @@
1
+ # 同梱処理で使う NE API 一覧(ne_api gem)
2
+
3
+ ne_bundling(同梱処理アプリ)が利用する NE API と、その gem 呼び出し名の一覧。
4
+ v0.0.23 で「同梱系API」を追加した。呼び出しは `NeAPI::Master#<model>_<method>` 形式。
5
+
6
+ ## v0.0.23 で追加した同梱系API
7
+
8
+ | gem 呼び出し | NE エンドポイント | 用途 | 主なパラメータ | 戻り値(get_key) |
9
+ | --- | --- | --- | --- | --- |
10
+ | `receiveorder_base_bundle` | `POST /api_v1_receiveorder_base/bundle` | 受注伝票の一括同梱(NE標準同梱処理を実行) | `params: { data: <JSON文字列>, receive_order_recalculate_flag: "1"/"0" }` | `results`(ジョブ毎の同梱結果配列) |
11
+ | `receiveorder_base_bundle_candidate_groups` | `POST /api_v1_receiveorder_base/bundle_candidate_groups` | 同梱候補グループ取得(同梱可能な受注をグループ化) | `params: { target_receive_order_ids: "1,2,3" }`(省略時は全受注対象) | `groups`(受注番号配列の配列) |
12
+ | `receiveorder_groupingtag_search` | `POST /api_v1_receiveorder_groupingtag/search` | 受注分類タグ検索 | `fields:`, `query:`(`grouping_tag_*`) | `data` |
13
+
14
+ ### `receiveorder_base_bundle` の `data` 構造
15
+
16
+ ```json
17
+ [
18
+ {
19
+ "receive_order_id": "同梱先(親)の受注伝票番号",
20
+ "receive_order_last_modified_date": "YYYY-MM-DD HH:MM:SS", // 楽観ロック用
21
+ "bundles": [
22
+ { "receive_order_id": "同梱元(子)の受注伝票番号",
23
+ "receive_order_last_modified_date": "YYYY-MM-DD HH:MM:SS" }
24
+ ]
25
+ }
26
+ ]
27
+ ```
28
+
29
+ - `data` 配列は 1〜100 ジョブ。`receive_order_last_modified_date` が DB の最終更新日と不一致の伝票はスキップされる。
30
+ - `results[].bundled_receive_order_ids` に成功した子注文、`skipped_receive_order_ids` / `skipped_receive_order_reasons` にスキップ分が返る。
31
+ - 同梱元が全件スキップになるとエラー(コード `028013`)。固有エラーは `028001`〜`028021`。
32
+
33
+ ### `bundle_candidate_groups` のグループ判定条件
34
+
35
+ 同一グループは次を全て満たす受注: ①同じ店舗 ②有効な伝票(未キャンセル)③受注状態が起票済/納品書印刷待ち/納品書印刷済 ④送り先名一致 ⑤送り先住所一致 ⑥送り先電話番号一致 ⑦送り先未マスク。
36
+ 固有エラー: `029001`(1万件超) / `029002`(非数値) / `029003`。
37
+
38
+ ## 同梱フローで使う既存API(v0.0.22 時点で定義済み)
39
+
40
+ | gem 呼び出し | NE エンドポイント | 用途 |
41
+ | --- | --- | --- |
42
+ | `receiveorder_row_search` / `_count` | `/api_v1_receiveorder_row/{search,count}` | 受注明細の検索・件数(同梱対象の絞り込み) |
43
+ | `receiveorder_base_search` / `_count` | `/api_v1_receiveorder_base/{search,count}` | 受注伝票の検索・件数(配送先・状態の取得) |
44
+ | `receiveorder_base_update` | `/api_v1_receiveorder_base/update` | 受注更新(商品追加・確認・タグ付与: XML) |
45
+ | `receiveorder_base_bulkupdate` | `/api_v1_receiveorder_base/bulkupdate` | 子注文の一括更新(キャンセル等: XML) |
46
+ | `master_goods_search` / `_count` | `/api_v1_master_goods/{search,count}` | 商品マスタ取得(商品名等の付与) |
47
+ | `master_shop_search` | `/api_v1_master_shop/search` | 店舗一覧取得(shop_id 絞り込み用) |
48
+ | `notice_execution_add` | `/api_v1_notice_execution/add` | 実行結果お知らせ登録 |
49
+ | `login_company_info` / `login_user_info` | `/api_v1_login_{company,user}/info` | 認証・企業/ユーザー情報 |
50
+
51
+ ## 補足
52
+
53
+ - 現行の同梱アプリ(`ne_bundling`)は `receiveorder_base_update` + `bulkupdate` を XML で組み立ててクライアント側で同梱を実装している。NE標準の `receiveorder_base_bundle` / `bundle_candidate_groups` を使うと、グループ判定〜同梱実行を NE 側に委譲でき、ロジックを大幅に簡素化できる(改修方針の選択肢)。
54
+ - 全エンドポイントの詳細仕様は ne_bundling 側 `doc/ne_api_reference.txt`(出典 https://developer.next-engine.com/llms-full.txt )を参照。
data/README.md CHANGED
@@ -266,6 +266,9 @@ This allows easy injection of `FakeMaster` in tests.
266
266
  5. Create a new Pull Request
267
267
 
268
268
  ## Update
269
+ ### ver0.0.23
270
+ * 同梱系APIに対応(受注伝票一括同梱 `receiveorder_base_bundle` / 同梱候補グループ取得 `receiveorder_base_bundle_candidate_groups` / 受注分類タグ検索 `receiveorder_groupingtag_search`)。詳細は [`BUNDLING_API.md`](BUNDLING_API.md) 参照
271
+ * `method_missing` を複数語メソッド対応に改修(登録モデル名の最長前方一致で解決。単一語メソッドは従来通りで後方互換)
269
272
  ### ver0.0.22
270
273
  * bug fix
271
274
  ### ver0.0.21
data/config/api.yaml CHANGED
@@ -218,6 +218,8 @@
218
218
  - divide
219
219
  - bulkupdate
220
220
  - bulkupdatereceipted
221
+ - bundle
222
+ - bundle_candidate_groups
221
223
  :prefix: receive_order
222
224
  :fields: shop_id,id,shop_cut_form_id,date,import_date,important_check_id,important_check_name,confirm_check_id,confirm_check_name,confirm_ids,mail_status,gruoping_tag,import_type_id,import_type_name,cancel_type_id,cancel_type_name,cancel_date,closed_after_edit_date,order_status_id,order_status_name,delivery_id,delivery_name,payment_method_id,payment_method_name,total_amount,tax_amount,charge_amount,delivery_fee_amount,other_amount,point_amount,goods_amount,deposit_amount,deposit_type_id,deposit_type_name,deposit_date,foreign_total_amount,foreign_tax_amount,foreign_charge_amount,foreign_delivery_fee_amount,foreign_other_amount,foreign_goods_amount,foreign_deposit_amount,note,include_possible_order_id,include_to_order_id,multi_delivery_parent_order_id,multi_delivery_parent_flag,statement_delivery_instruct_printing_date,statement_delivery_printing_date,statement_delivery_text,send_date,send_plan_date,send_sequence,worker_text,picking_instruct,picking_min_supplier_id,picking_min_goods_id,label_print_date,label_print_flag,hope_delivery_date,hope_delivery_time_slot_id,hope_delivery_time_slot_name,delivery_method_id,delivery_method_name,seal1_id,seal1_name,seal2_id,seal2_name,seal3_id,seal3_name,seal4_id,seal4_name,business_office_stop_id,business_office_stop_name,invoice_id,invoice_name,temperature_id,temperature_name,business_office_name,gift_flag,delivery_cut_form_id,delivery_cut_form_note,credit_type_id,credit_type_name,credit_approval_no,credit_approval_amount,credit_approval_type_id,credit_approval_type_name,credit_approval_date,credit_approval_rate,credit_number_payments,credit_authorization_center_id,credit_authorization_center_name,credit_approval_fax_printing_date,customer_type_id,customer_type_name,customer_id,purchaser_name,purchaser_kana,purchaser_zip_code,purchaser_address1,purchaser_address2,purchaser_tel,purchaser_fax,purchaser_mail_address,consignee_name,consignee_kana,consignee_zip_code,consignee_address1,consignee_address2,consignee_tel,consignee_fax,reminder_start_date,reminder_last_date,reminder_count,important_check_pic_id,important_check_pic_name,pic_id,pic_name,send_pic_id,send_pic_name,deleted_flag,creation_date,last_modified_date,last_modified_null_safe_date,creator_id,creator_name,last_modified_by_id,last_modified_by_null_safe_id,last_modified_by_name,last_modified_by_null_safe_name
223
225
  :receiveorder_option:
@@ -245,6 +247,11 @@
245
247
  - update
246
248
  :prefix: confirm
247
249
  :fields: id,name,display_order,html,value,valid_flag
250
+ :receiveorder_groupingtag:
251
+ :method:
252
+ - search
253
+ :prefix: grouping_tag
254
+ :fields: id,name,color,str_color,memo,creation_date,last_modified_date,last_modified_null_safe_date,creator_id,creator_name,last_modified_by_id,last_modified_by_null_safe_id,last_modified_by_name,last_modified_by_null_safe_name
248
255
  :receiveorder_paymentdeliveryconvert:
249
256
  :method:
250
257
  - count
@@ -1,3 +1,3 @@
1
1
  module NeApi
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
data/lib/ne_api.rb CHANGED
@@ -93,13 +93,25 @@ module NeAPI
93
93
  end
94
94
  def method_missing(path, args={})
95
95
  super if @@params.nil? || path.nil?
96
- unless models = /^(.*)_.*$/.match(path.to_s)
97
- super
96
+
97
+ # path を「モデル名_メソッド名」に分解する。
98
+ # 旧実装は最後の "_" で分割していたが、bundle_candidate_groups のような
99
+ # 複数語メソッドに対応できなかった。登録済みモデル名との前方一致(最長一致優先)で
100
+ # 解決することで、単語数によらず正しい model / method を取り出す。
101
+ # 単一語メソッドでは旧実装と同じ結果になるため後方互換。
102
+ model = nil
103
+ method = nil
104
+ @@params.keys.sort_by { |key| -key.to_s.length }.each do |key|
105
+ prefix = "#{key}_"
106
+ next unless path.to_s.start_with?(prefix)
107
+ candidate = path.to_s[prefix.length..-1]
108
+ next unless @@params[key][:method].include?(candidate)
109
+ model = key
110
+ method = candidate
111
+ break
98
112
  end
99
- model = models.captures.first.to_sym
100
- method = path.to_s.split("_").last
101
113
 
102
- if @@params.key?(model) && @@params[model][:method].include?(method)
114
+ if model
103
115
  get_key = nil
104
116
  query = (args[:query].present? ? args[:query] : nil)
105
117
  fields = (args[:fields].present? ? args[:fields] : nil)
@@ -119,6 +131,12 @@ module NeAPI
119
131
  get_key = "result"
120
132
  when "divide"
121
133
  get_key = "receive_order_id"
134
+ when "bundle"
135
+ # 受注伝票一括同梱: ジョブ毎の結果配列(results)を返す
136
+ get_key = "results"
137
+ when "bundle_candidate_groups"
138
+ # 同梱候補グループ取得: 同梱可能な受注番号配列の配列(groups)を返す
139
+ get_key = "groups"
122
140
  when "checkconnect"
123
141
  fields = nil
124
142
  get_key = nil
@@ -0,0 +1,90 @@
1
+ # 同梱系API追加(v0.0.23)に伴う method_missing ディスパッチの検証。
2
+ # 実APIには接続せず、post を差し替えて model / method / get_key の解決のみを検証する。
3
+ #
4
+ # 実行: rspec spec/bundling_dispatch_spec.rb (bundle exec 不要 / グローバルgem使用)
5
+
6
+ require_relative "../lib/ne_api"
7
+
8
+ RSpec.describe NeAPI::Master do
9
+ subject(:master) { described_class.new(access_token: "a", refresh_token: "r") }
10
+
11
+ # post を差し替え、method_missing が組み立てた引数をそのまま返させる
12
+ before do
13
+ allow(master).to receive(:post) { |**kwargs| kwargs }
14
+ end
15
+
16
+ describe "既存メソッドのディスパッチ(後方互換)" do
17
+ it "receiveorder_base_search は search に解決される" do
18
+ result = master.receiveorder_base_search
19
+ expect(result).to include(model: :receiveorder_base, method: "search", get_key: "data")
20
+ end
21
+
22
+ it "件数取得は count / get_key=count に解決される" do
23
+ expect(master.receiveorder_base_count).to include(method: "count", get_key: "count")
24
+ end
25
+
26
+ it "info系は info / get_key=nil に解決される" do
27
+ expect(master.login_company_info).to include(model: :login_company, method: "info", get_key: nil)
28
+ end
29
+
30
+ it "一括更新は bulkupdate / get_key=result に解決される" do
31
+ expect(master.receiveorder_base_bulkupdate).to include(method: "bulkupdate", get_key: "result")
32
+ end
33
+ end
34
+
35
+ describe "モデル名の前方一致が曖昧なケースの解決" do
36
+ it "master_goods_search は master_goods に解決される" do
37
+ expect(master.master_goods_search).to include(model: :master_goods, method: "search")
38
+ end
39
+
40
+ it "master_goods_page_search はより長い master_goods_page に解決される" do
41
+ expect(master.master_goods_page_search).to include(model: :master_goods_page, method: "search")
42
+ end
43
+
44
+ it "master_goods_page_variation_search は最長一致の master_goods_page_variation に解決される" do
45
+ expect(master.master_goods_page_variation_search)
46
+ .to include(model: :master_goods_page_variation, method: "search")
47
+ end
48
+ end
49
+
50
+ describe "同梱系API(v0.0.23 で追加)" do
51
+ it "receiveorder_base_bundle は bundle / get_key=results に解決される" do
52
+ result = master.receiveorder_base_bundle(params: { data: "[]", receive_order_recalculate_flag: 1 })
53
+ expect(result).to include(model: :receiveorder_base, method: "bundle", get_key: "results")
54
+ end
55
+
56
+ it "bundle は params をそのまま post へ渡す" do
57
+ params = { data: "[{\"receive_order_id\":\"1\"}]", receive_order_recalculate_flag: 1 }
58
+ expect(master.receiveorder_base_bundle(params: params)).to include(params: params)
59
+ end
60
+
61
+ it "複数語メソッド bundle_candidate_groups が groups に解決される" do
62
+ result = master.receiveorder_base_bundle_candidate_groups(params: { target_receive_order_ids: "1,2,3" })
63
+ expect(result).to include(
64
+ model: :receiveorder_base,
65
+ method: "bundle_candidate_groups",
66
+ get_key: "groups"
67
+ )
68
+ end
69
+
70
+ it "receiveorder_groupingtag_search は新規モデルとして search に解決される" do
71
+ result = master.receiveorder_groupingtag_search
72
+ expect(result).to include(model: :receiveorder_groupingtag, method: "search", get_key: "data")
73
+ end
74
+
75
+ it "groupingtag_search はデフォルトfieldsに grouping_tag_ プレフィックスを付与する" do
76
+ expect(master.receiveorder_groupingtag_search[:fields]).to start_with("grouping_tag_id,")
77
+ end
78
+ end
79
+
80
+ describe "未定義メソッド" do
81
+ it "存在しないAPIは NoMethodError を送出する" do
82
+ expect { master.nonexistent_foo }.to raise_error(NoMethodError)
83
+ end
84
+
85
+ it "存在するモデルでも未定義のメソッドは NoMethodError を送出する" do
86
+ # receiveorder_groupingtag は search のみ。update は未定義。
87
+ expect { master.receiveorder_groupingtag_update }.to raise_error(NoMethodError)
88
+ end
89
+ end
90
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ne_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuuna Kurita
@@ -145,6 +145,7 @@ extra_rdoc_files: []
145
145
  files:
146
146
  - ".env"
147
147
  - ".gitignore"
148
+ - BUNDLING_API.md
148
149
  - Gemfile
149
150
  - LICENSE.txt
150
151
  - README.md
@@ -158,6 +159,7 @@ files:
158
159
  - lib/ne_api/testing/rspec_helpers.rb
159
160
  - lib/ne_api/version.rb
160
161
  - ne_api.gemspec
162
+ - spec/bundling_dispatch_spec.rb
161
163
  - spec/ne_api_spec.rb
162
164
  homepage: http://github.com/infinity-octaver/ne_api/
163
165
  licenses:
@@ -181,4 +183,5 @@ rubygems_version: 4.0.1
181
183
  specification_version: 4
182
184
  summary: Next Engine API for ruby
183
185
  test_files:
186
+ - spec/bundling_dispatch_spec.rb
184
187
  - spec/ne_api_spec.rb