tachain-sdk 0.1.0

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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +21 -0
  4. data/README.md +226 -0
  5. data/Rakefile +10 -0
  6. data/git_push.sh +54 -0
  7. data/lib/tachain-sdk/api/api_declaration_api.rb +396 -0
  8. data/lib/tachain-sdk/api/api_delivery_api.rb +676 -0
  9. data/lib/tachain-sdk/api/api_enum_api.rb +94 -0
  10. data/lib/tachain-sdk/api/api_order_api.rb +846 -0
  11. data/lib/tachain-sdk/api/api_order_workflow_api.rb +170 -0
  12. data/lib/tachain-sdk/api/api_production_api.rb +466 -0
  13. data/lib/tachain-sdk/api_client.rb +397 -0
  14. data/lib/tachain-sdk/api_error.rb +58 -0
  15. data/lib/tachain-sdk/api_model_base.rb +88 -0
  16. data/lib/tachain-sdk/configuration.rb +329 -0
  17. data/lib/tachain-sdk/models/api_declaration_delete_request.rb +341 -0
  18. data/lib/tachain-sdk/models/api_declaration_document_request.rb +209 -0
  19. data/lib/tachain-sdk/models/api_declaration_list_dto.rb +251 -0
  20. data/lib/tachain-sdk/models/api_declaration_submit_request.rb +251 -0
  21. data/lib/tachain-sdk/models/api_declaration_submit_result_dto.rb +197 -0
  22. data/lib/tachain-sdk/models/api_integration_delete_request.rb +209 -0
  23. data/lib/tachain-sdk/models/api_order_confirm_receipt_request.rb +216 -0
  24. data/lib/tachain-sdk/models/api_order_submit_audit_request.rb +243 -0
  25. data/lib/tachain-sdk/models/api_response_api_declaration_list_dto.rb +199 -0
  26. data/lib/tachain-sdk/models/api_response_api_declaration_submit_result_dto.rb +199 -0
  27. data/lib/tachain-sdk/models/api_response_delivery_note_api_dto.rb +199 -0
  28. data/lib/tachain-sdk/models/api_response_order_api_dto.rb +199 -0
  29. data/lib/tachain-sdk/models/api_response_production_api_dto.rb +199 -0
  30. data/lib/tachain-sdk/models/api_response_string.rb +200 -0
  31. data/lib/tachain-sdk/models/attachment_in_api_create_dto.rb +262 -0
  32. data/lib/tachain-sdk/models/attachment_in_api_dto.rb +363 -0
  33. data/lib/tachain-sdk/models/brand_kpi_policy_result.rb +334 -0
  34. data/lib/tachain-sdk/models/brand_order_kpi_snapshot_dto.rb +880 -0
  35. data/lib/tachain-sdk/models/brand_order_supplier_order_snapshot_dto.rb +749 -0
  36. data/lib/tachain-sdk/models/brand_order_uncompleted_declare_snapshot_dto.rb +513 -0
  37. data/lib/tachain-sdk/models/company.rb +780 -0
  38. data/lib/tachain-sdk/models/company_compliance_profile.rb +547 -0
  39. data/lib/tachain-sdk/models/company_utility_declaration.rb +592 -0
  40. data/lib/tachain-sdk/models/customer.rb +569 -0
  41. data/lib/tachain-sdk/models/delivery_note_api_dto.rb +597 -0
  42. data/lib/tachain-sdk/models/delivery_note_detail_api_dto.rb +682 -0
  43. data/lib/tachain-sdk/models/document_type_api_dto.rb +480 -0
  44. data/lib/tachain-sdk/models/factory.rb +545 -0
  45. data/lib/tachain-sdk/models/get_v1_enum_get_list200_response.rb +201 -0
  46. data/lib/tachain-sdk/models/microsoft_asp_net_core_mvc_problem_details.rb +188 -0
  47. data/lib/tachain-sdk/models/model1.rb +157 -0
  48. data/lib/tachain-sdk/models/model3.rb +202 -0
  49. data/lib/tachain-sdk/models/model4.rb +202 -0
  50. data/lib/tachain-sdk/models/order.rb +974 -0
  51. data/lib/tachain-sdk/models/order_api_dto.rb +918 -0
  52. data/lib/tachain-sdk/models/order_line.rb +1184 -0
  53. data/lib/tachain-sdk/models/order_line_api_dto.rb +1277 -0
  54. data/lib/tachain-sdk/models/order_stage_form_api_dto.rb +270 -0
  55. data/lib/tachain-sdk/models/order_stage_form_datum_api_dto.rb +260 -0
  56. data/lib/tachain-sdk/models/order_stage_form_dto.rb +254 -0
  57. data/lib/tachain-sdk/models/paged_response_delivery_note_api_dto.rb +296 -0
  58. data/lib/tachain-sdk/models/paged_response_order_api_dto.rb +296 -0
  59. data/lib/tachain-sdk/models/paged_response_production_api_dto.rb +296 -0
  60. data/lib/tachain-sdk/models/product_bom_grouping_dto.rb +280 -0
  61. data/lib/tachain-sdk/models/production_api_dto.rb +639 -0
  62. data/lib/tachain-sdk/models/production_raw_material_api_dto.rb +481 -0
  63. data/lib/tachain-sdk/models/production_raw_material_dto.rb +548 -0
  64. data/lib/tachain-sdk/models/production_sales_order_api_dto.rb +436 -0
  65. data/lib/tachain-sdk/models/result_api_enum.rb +270 -0
  66. data/lib/tachain-sdk/models/result_brand_report_allocated_delivery_kpi_detail.rb +331 -0
  67. data/lib/tachain-sdk/models/result_brand_report_unlinked_order_detail.rb +229 -0
  68. data/lib/tachain-sdk/models/result_kpi_archived_data_change_detail.rb +418 -0
  69. data/lib/tachain-sdk/models/result_mapping_order_select.rb +335 -0
  70. data/lib/tachain-sdk/models/result_order_trace_report.rb +721 -0
  71. data/lib/tachain-sdk/models/stage_attachment_api_dto.rb +398 -0
  72. data/lib/tachain-sdk/models/supplier.rb +585 -0
  73. data/lib/tachain-sdk/models/supplier_onboarding_ext.rb +383 -0
  74. data/lib/tachain-sdk/models/template_dto_business_risk_warn_info_dto.rb +456 -0
  75. data/lib/tachain-sdk/models/template_dto_multi_so_line_complete_status.rb +227 -0
  76. data/lib/tachain-sdk/models/trader.rb +506 -0
  77. data/lib/tachain-sdk/signed_api_client.rb +65 -0
  78. data/lib/tachain-sdk/version.rb +15 -0
  79. data/lib/tachain-sdk.rb +108 -0
  80. data/spec/spec_helper.rb +111 -0
  81. data/tachain-sdk.gemspec +39 -0
  82. metadata +165 -0
@@ -0,0 +1,506 @@
1
+ =begin
2
+ #Tactic Chain Public API
3
+
4
+ #Public integration endpoints. Set your own base URL and credential before calling.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TachainSdk
17
+ # 贸易商表
18
+ class Trader < ApiModelBase
19
+ # 贸易商ID
20
+ attr_accessor :id
21
+
22
+ # 关联的公司ID
23
+ attr_accessor :company_id
24
+
25
+ # 销售范围,单选,只需要到第一级
26
+ attr_accessor :sales_scope
27
+
28
+ # -9 禁用, -1 删除, 0 正常
29
+ attr_accessor :status
30
+
31
+ # 租户ID
32
+ attr_accessor :tenant_id
33
+
34
+ # 环境类型:0 正式, 1 测试
35
+ attr_accessor :environment_type
36
+
37
+ # 创建用户ID
38
+ attr_accessor :created_by
39
+
40
+ # 修改用户ID
41
+ attr_accessor :updated_by
42
+
43
+ # 创建时间
44
+ attr_accessor :created_at
45
+
46
+ # 更新时间
47
+ attr_accessor :updated_at
48
+
49
+ # 公司类型 0 自有,1 集团控股,2 合约委托
50
+ attr_accessor :company_type
51
+
52
+ # 对外接单标识 0 接单, -1 不接单
53
+ attr_accessor :accept_order
54
+
55
+ # 审核状态:101 草稿,102 待审核 ,103 重新提交待审, 111 取消审核, 113 审核作废, 114 审核驳回, 115 审核拒绝, 120 审核通过
56
+ attr_accessor :audit_status
57
+
58
+ # 部门ID
59
+ attr_accessor :division_id
60
+
61
+ # 贸易地区
62
+ attr_accessor :trade_regions
63
+
64
+ # 主营产品
65
+ attr_accessor :main_products
66
+
67
+ # 年营业额
68
+ attr_accessor :annual_turnover
69
+
70
+ # 备注
71
+ attr_accessor :remark
72
+
73
+ attr_accessor :company
74
+
75
+ # Attribute mapping from ruby-style variable name to JSON key.
76
+ def self.attribute_map
77
+ {
78
+ :'id' => :'id',
79
+ :'company_id' => :'companyId',
80
+ :'sales_scope' => :'salesScope',
81
+ :'status' => :'status',
82
+ :'tenant_id' => :'tenantId',
83
+ :'environment_type' => :'environmentType',
84
+ :'created_by' => :'createdBy',
85
+ :'updated_by' => :'updatedBy',
86
+ :'created_at' => :'createdAt',
87
+ :'updated_at' => :'updatedAt',
88
+ :'company_type' => :'companyType',
89
+ :'accept_order' => :'acceptOrder',
90
+ :'audit_status' => :'auditStatus',
91
+ :'division_id' => :'divisionId',
92
+ :'trade_regions' => :'tradeRegions',
93
+ :'main_products' => :'mainProducts',
94
+ :'annual_turnover' => :'annualTurnover',
95
+ :'remark' => :'remark',
96
+ :'company' => :'company'
97
+ }
98
+ end
99
+
100
+ # Returns attribute mapping this model knows about
101
+ def self.acceptable_attribute_map
102
+ attribute_map
103
+ end
104
+
105
+ # Returns all the JSON keys this model knows about
106
+ def self.acceptable_attributes
107
+ acceptable_attribute_map.values
108
+ end
109
+
110
+ # Attribute type mapping.
111
+ def self.openapi_types
112
+ {
113
+ :'id' => :'String',
114
+ :'company_id' => :'String',
115
+ :'sales_scope' => :'String',
116
+ :'status' => :'Integer',
117
+ :'tenant_id' => :'String',
118
+ :'environment_type' => :'Integer',
119
+ :'created_by' => :'String',
120
+ :'updated_by' => :'String',
121
+ :'created_at' => :'Time',
122
+ :'updated_at' => :'Time',
123
+ :'company_type' => :'Integer',
124
+ :'accept_order' => :'Integer',
125
+ :'audit_status' => :'Integer',
126
+ :'division_id' => :'String',
127
+ :'trade_regions' => :'String',
128
+ :'main_products' => :'String',
129
+ :'annual_turnover' => :'Float',
130
+ :'remark' => :'String',
131
+ :'company' => :'Company'
132
+ }
133
+ end
134
+
135
+ # List of attributes with nullable: true
136
+ def self.openapi_nullable
137
+ Set.new([
138
+ :'updated_by',
139
+ :'updated_at',
140
+ :'accept_order',
141
+ :'division_id',
142
+ :'trade_regions',
143
+ :'main_products',
144
+ :'annual_turnover',
145
+ :'remark',
146
+ ])
147
+ end
148
+
149
+ # Initializes the object
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ def initialize(attributes = {})
152
+ if (!attributes.is_a?(Hash))
153
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TachainSdk::Trader` initialize method"
154
+ end
155
+
156
+ # check to see if the attribute exists and convert string to symbol for hash key
157
+ acceptable_attribute_map = self.class.acceptable_attribute_map
158
+ attributes = attributes.each_with_object({}) { |(k, v), h|
159
+ if (!acceptable_attribute_map.key?(k.to_sym))
160
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TachainSdk::Trader`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
161
+ end
162
+ h[k.to_sym] = v
163
+ }
164
+
165
+ if attributes.key?(:'id')
166
+ self.id = attributes[:'id']
167
+ else
168
+ self.id = nil
169
+ end
170
+
171
+ if attributes.key?(:'company_id')
172
+ self.company_id = attributes[:'company_id']
173
+ else
174
+ self.company_id = nil
175
+ end
176
+
177
+ if attributes.key?(:'sales_scope')
178
+ self.sales_scope = attributes[:'sales_scope']
179
+ else
180
+ self.sales_scope = nil
181
+ end
182
+
183
+ if attributes.key?(:'status')
184
+ self.status = attributes[:'status']
185
+ else
186
+ self.status = nil
187
+ end
188
+
189
+ if attributes.key?(:'tenant_id')
190
+ self.tenant_id = attributes[:'tenant_id']
191
+ else
192
+ self.tenant_id = nil
193
+ end
194
+
195
+ if attributes.key?(:'environment_type')
196
+ self.environment_type = attributes[:'environment_type']
197
+ else
198
+ self.environment_type = nil
199
+ end
200
+
201
+ if attributes.key?(:'created_by')
202
+ self.created_by = attributes[:'created_by']
203
+ else
204
+ self.created_by = nil
205
+ end
206
+
207
+ if attributes.key?(:'updated_by')
208
+ self.updated_by = attributes[:'updated_by']
209
+ end
210
+
211
+ if attributes.key?(:'created_at')
212
+ self.created_at = attributes[:'created_at']
213
+ else
214
+ self.created_at = nil
215
+ end
216
+
217
+ if attributes.key?(:'updated_at')
218
+ self.updated_at = attributes[:'updated_at']
219
+ end
220
+
221
+ if attributes.key?(:'company_type')
222
+ self.company_type = attributes[:'company_type']
223
+ else
224
+ self.company_type = nil
225
+ end
226
+
227
+ if attributes.key?(:'accept_order')
228
+ self.accept_order = attributes[:'accept_order']
229
+ end
230
+
231
+ if attributes.key?(:'audit_status')
232
+ self.audit_status = attributes[:'audit_status']
233
+ else
234
+ self.audit_status = nil
235
+ end
236
+
237
+ if attributes.key?(:'division_id')
238
+ self.division_id = attributes[:'division_id']
239
+ end
240
+
241
+ if attributes.key?(:'trade_regions')
242
+ self.trade_regions = attributes[:'trade_regions']
243
+ end
244
+
245
+ if attributes.key?(:'main_products')
246
+ self.main_products = attributes[:'main_products']
247
+ end
248
+
249
+ if attributes.key?(:'annual_turnover')
250
+ self.annual_turnover = attributes[:'annual_turnover']
251
+ end
252
+
253
+ if attributes.key?(:'remark')
254
+ self.remark = attributes[:'remark']
255
+ end
256
+
257
+ if attributes.key?(:'company')
258
+ self.company = attributes[:'company']
259
+ end
260
+ end
261
+
262
+ # Show invalid properties with the reasons. Usually used together with valid?
263
+ # @return Array for valid properties with the reasons
264
+ def list_invalid_properties
265
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
266
+ invalid_properties = Array.new
267
+ if @id.nil?
268
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
269
+ end
270
+
271
+ if @company_id.nil?
272
+ invalid_properties.push('invalid value for "company_id", company_id cannot be nil.')
273
+ end
274
+
275
+ if @sales_scope.nil?
276
+ invalid_properties.push('invalid value for "sales_scope", sales_scope cannot be nil.')
277
+ end
278
+
279
+ if @status.nil?
280
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
281
+ end
282
+
283
+ if @tenant_id.nil?
284
+ invalid_properties.push('invalid value for "tenant_id", tenant_id cannot be nil.')
285
+ end
286
+
287
+ if @environment_type.nil?
288
+ invalid_properties.push('invalid value for "environment_type", environment_type cannot be nil.')
289
+ end
290
+
291
+ if @created_by.nil?
292
+ invalid_properties.push('invalid value for "created_by", created_by cannot be nil.')
293
+ end
294
+
295
+ if @created_at.nil?
296
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
297
+ end
298
+
299
+ if @company_type.nil?
300
+ invalid_properties.push('invalid value for "company_type", company_type cannot be nil.')
301
+ end
302
+
303
+ if @audit_status.nil?
304
+ invalid_properties.push('invalid value for "audit_status", audit_status cannot be nil.')
305
+ end
306
+
307
+ invalid_properties
308
+ end
309
+
310
+ # Check to see if the all the properties in the model are valid
311
+ # @return true if the model is valid
312
+ def valid?
313
+ warn '[DEPRECATED] the `valid?` method is obsolete'
314
+ return false if @id.nil?
315
+ return false if @company_id.nil?
316
+ return false if @sales_scope.nil?
317
+ return false if @status.nil?
318
+ return false if @tenant_id.nil?
319
+ return false if @environment_type.nil?
320
+ return false if @created_by.nil?
321
+ return false if @created_at.nil?
322
+ return false if @company_type.nil?
323
+ return false if @audit_status.nil?
324
+ true
325
+ end
326
+
327
+ # Custom attribute writer method with validation
328
+ # @param [Object] id Value to be assigned
329
+ def id=(id)
330
+ if id.nil?
331
+ fail ArgumentError, 'id cannot be nil'
332
+ end
333
+
334
+ @id = id
335
+ end
336
+
337
+ # Custom attribute writer method with validation
338
+ # @param [Object] company_id Value to be assigned
339
+ def company_id=(company_id)
340
+ if company_id.nil?
341
+ fail ArgumentError, 'company_id cannot be nil'
342
+ end
343
+
344
+ @company_id = company_id
345
+ end
346
+
347
+ # Custom attribute writer method with validation
348
+ # @param [Object] sales_scope Value to be assigned
349
+ def sales_scope=(sales_scope)
350
+ if sales_scope.nil?
351
+ fail ArgumentError, 'sales_scope cannot be nil'
352
+ end
353
+
354
+ @sales_scope = sales_scope
355
+ end
356
+
357
+ # Custom attribute writer method with validation
358
+ # @param [Object] status Value to be assigned
359
+ def status=(status)
360
+ if status.nil?
361
+ fail ArgumentError, 'status cannot be nil'
362
+ end
363
+
364
+ @status = status
365
+ end
366
+
367
+ # Custom attribute writer method with validation
368
+ # @param [Object] tenant_id Value to be assigned
369
+ def tenant_id=(tenant_id)
370
+ if tenant_id.nil?
371
+ fail ArgumentError, 'tenant_id cannot be nil'
372
+ end
373
+
374
+ @tenant_id = tenant_id
375
+ end
376
+
377
+ # Custom attribute writer method with validation
378
+ # @param [Object] environment_type Value to be assigned
379
+ def environment_type=(environment_type)
380
+ if environment_type.nil?
381
+ fail ArgumentError, 'environment_type cannot be nil'
382
+ end
383
+
384
+ @environment_type = environment_type
385
+ end
386
+
387
+ # Custom attribute writer method with validation
388
+ # @param [Object] created_by Value to be assigned
389
+ def created_by=(created_by)
390
+ if created_by.nil?
391
+ fail ArgumentError, 'created_by cannot be nil'
392
+ end
393
+
394
+ @created_by = created_by
395
+ end
396
+
397
+ # Custom attribute writer method with validation
398
+ # @param [Object] created_at Value to be assigned
399
+ def created_at=(created_at)
400
+ if created_at.nil?
401
+ fail ArgumentError, 'created_at cannot be nil'
402
+ end
403
+
404
+ @created_at = created_at
405
+ end
406
+
407
+ # Custom attribute writer method with validation
408
+ # @param [Object] company_type Value to be assigned
409
+ def company_type=(company_type)
410
+ if company_type.nil?
411
+ fail ArgumentError, 'company_type cannot be nil'
412
+ end
413
+
414
+ @company_type = company_type
415
+ end
416
+
417
+ # Custom attribute writer method with validation
418
+ # @param [Object] audit_status Value to be assigned
419
+ def audit_status=(audit_status)
420
+ if audit_status.nil?
421
+ fail ArgumentError, 'audit_status cannot be nil'
422
+ end
423
+
424
+ @audit_status = audit_status
425
+ end
426
+
427
+ # Checks equality by comparing each attribute.
428
+ # @param [Object] Object to be compared
429
+ def ==(o)
430
+ return true if self.equal?(o)
431
+ self.class == o.class &&
432
+ id == o.id &&
433
+ company_id == o.company_id &&
434
+ sales_scope == o.sales_scope &&
435
+ status == o.status &&
436
+ tenant_id == o.tenant_id &&
437
+ environment_type == o.environment_type &&
438
+ created_by == o.created_by &&
439
+ updated_by == o.updated_by &&
440
+ created_at == o.created_at &&
441
+ updated_at == o.updated_at &&
442
+ company_type == o.company_type &&
443
+ accept_order == o.accept_order &&
444
+ audit_status == o.audit_status &&
445
+ division_id == o.division_id &&
446
+ trade_regions == o.trade_regions &&
447
+ main_products == o.main_products &&
448
+ annual_turnover == o.annual_turnover &&
449
+ remark == o.remark &&
450
+ company == o.company
451
+ end
452
+
453
+ # @see the `==` method
454
+ # @param [Object] Object to be compared
455
+ def eql?(o)
456
+ self == o
457
+ end
458
+
459
+ # Calculates hash code according to all attributes.
460
+ # @return [Integer] Hash code
461
+ def hash
462
+ [id, company_id, sales_scope, status, tenant_id, environment_type, created_by, updated_by, created_at, updated_at, company_type, accept_order, audit_status, division_id, trade_regions, main_products, annual_turnover, remark, company].hash
463
+ end
464
+
465
+ # Builds the object from hash
466
+ # @param [Hash] attributes Model attributes in the form of hash
467
+ # @return [Object] Returns the model itself
468
+ def self.build_from_hash(attributes)
469
+ return nil unless attributes.is_a?(Hash)
470
+ attributes = attributes.transform_keys(&:to_sym)
471
+ transformed_hash = {}
472
+ openapi_types.each_pair do |key, type|
473
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
474
+ transformed_hash["#{key}"] = nil
475
+ elsif type =~ /\AArray<(.*)>/i
476
+ # check to ensure the input is an array given that the attribute
477
+ # is documented as an array but the input is not
478
+ if attributes[attribute_map[key]].is_a?(Array)
479
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
480
+ end
481
+ elsif !attributes[attribute_map[key]].nil?
482
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
483
+ end
484
+ end
485
+ new(transformed_hash)
486
+ end
487
+
488
+ # Returns the object in the form of hash
489
+ # @return [Hash] Returns the object in the form of hash
490
+ def to_hash
491
+ hash = {}
492
+ self.class.attribute_map.each_pair do |attr, param|
493
+ value = self.send(attr)
494
+ if value.nil?
495
+ is_nullable = self.class.openapi_nullable.include?(attr)
496
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
497
+ end
498
+
499
+ hash[param] = _to_hash(value)
500
+ end
501
+ hash
502
+ end
503
+
504
+ end
505
+
506
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
4
+ require 'uri'
5
+ require 'openssl'
6
+ require 'tachain-sdk/api_client'
7
+
8
+ module TachainSdk
9
+ # Signs Typhoeus' fully serialized URL immediately before it sends the request.
10
+ class SignedApiClient < ApiClient
11
+ attr_reader :api_key
12
+
13
+ def initialize(config = Configuration.default, api_key:, api_secret:, clock: -> { Time.now.to_i })
14
+ super(config)
15
+ # OpenAPI `form` + `explode: true` arrays must become repeated keys.
16
+ @config.params_encoding ||= :multi
17
+ @api_key = api_key
18
+ @api_secret = api_secret
19
+ @clock = clock
20
+ end
21
+
22
+ def self.normalize_query(url)
23
+ query = URI.parse(url).query.to_s
24
+ groups = {}
25
+ query.split('&').each do |part|
26
+ next if part.empty?
27
+
28
+ raw_key, raw_value = part.split('=', 2)
29
+ key = CGI.unescape(raw_key)
30
+ value = CGI.unescape(raw_value.to_s)
31
+ # QueryHelpers.ParseQuery uses a case-insensitive dictionary and keeps
32
+ # the first spelling when the same key appears with another casing.
33
+ lookup = key.downcase
34
+ groups[lookup] ||= { key: key, values: [] }
35
+ groups[lookup][:values] << value
36
+ end
37
+ ordinal = ->(text) { text.encode(Encoding::UTF_16BE).b }
38
+ groups.values.sort_by { |group| ordinal.call(group[:key]) }.flat_map do |group|
39
+ group[:values].sort_by { |value| ordinal.call(value) }.map do |value|
40
+ "#{group[:key]}=#{value}"
41
+ end
42
+ end.join('&')
43
+ end
44
+
45
+ def self.compute_signature(api_key, api_secret, timestamp, url)
46
+ content = api_key + timestamp + normalize_query(url)
47
+ OpenSSL::HMAC.hexdigest('SHA256', api_secret, content)
48
+ end
49
+
50
+ def build_request(http_method, path, opts = {})
51
+ request = super
52
+ timestamp = @clock.call.to_i.to_s
53
+ headers = request.options[:headers]
54
+ %w[Authorization X-Credential-Type X-API-Key X-Timestamp X-Signature].each do |name|
55
+ headers.delete(name)
56
+ headers.delete(name.to_sym)
57
+ end
58
+ headers['X-Credential-Type'] = 'API Key'
59
+ headers['X-API-Key'] = @api_key
60
+ headers['X-Timestamp'] = timestamp
61
+ headers['X-Signature'] = self.class.compute_signature(@api_key, @api_secret, timestamp, request.url)
62
+ request
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,15 @@
1
+ =begin
2
+ #Tactic Chain Public API
3
+
4
+ #Public integration endpoints. Set your own base URL and credential before calling.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ module TachainSdk
14
+ VERSION = '0.1.0'
15
+ end
@@ -0,0 +1,108 @@
1
+ =begin
2
+ #Tactic Chain Public API
3
+
4
+ #Public integration endpoints. Set your own base URL and credential before calling.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.25.0
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'tachain-sdk/api_client'
15
+ require 'tachain-sdk/api_error'
16
+ require 'tachain-sdk/api_model_base'
17
+ require 'tachain-sdk/version'
18
+ require 'tachain-sdk/configuration'
19
+
20
+ # Models
21
+ require 'tachain-sdk/models/api_declaration_delete_request'
22
+ require 'tachain-sdk/models/api_declaration_document_request'
23
+ require 'tachain-sdk/models/api_declaration_list_dto'
24
+ require 'tachain-sdk/models/api_declaration_submit_request'
25
+ require 'tachain-sdk/models/api_declaration_submit_result_dto'
26
+ require 'tachain-sdk/models/api_integration_delete_request'
27
+ require 'tachain-sdk/models/api_order_confirm_receipt_request'
28
+ require 'tachain-sdk/models/api_order_submit_audit_request'
29
+ require 'tachain-sdk/models/api_response_api_declaration_list_dto'
30
+ require 'tachain-sdk/models/api_response_api_declaration_submit_result_dto'
31
+ require 'tachain-sdk/models/api_response_delivery_note_api_dto'
32
+ require 'tachain-sdk/models/api_response_order_api_dto'
33
+ require 'tachain-sdk/models/api_response_production_api_dto'
34
+ require 'tachain-sdk/models/api_response_string'
35
+ require 'tachain-sdk/models/attachment_in_api_create_dto'
36
+ require 'tachain-sdk/models/attachment_in_api_dto'
37
+ require 'tachain-sdk/models/brand_kpi_policy_result'
38
+ require 'tachain-sdk/models/brand_order_kpi_snapshot_dto'
39
+ require 'tachain-sdk/models/brand_order_supplier_order_snapshot_dto'
40
+ require 'tachain-sdk/models/brand_order_uncompleted_declare_snapshot_dto'
41
+ require 'tachain-sdk/models/company'
42
+ require 'tachain-sdk/models/company_compliance_profile'
43
+ require 'tachain-sdk/models/company_utility_declaration'
44
+ require 'tachain-sdk/models/customer'
45
+ require 'tachain-sdk/models/delivery_note_api_dto'
46
+ require 'tachain-sdk/models/delivery_note_detail_api_dto'
47
+ require 'tachain-sdk/models/document_type_api_dto'
48
+ require 'tachain-sdk/models/factory'
49
+ require 'tachain-sdk/models/get_v1_enum_get_list200_response'
50
+ require 'tachain-sdk/models/microsoft_asp_net_core_mvc_problem_details'
51
+ require 'tachain-sdk/models/model1'
52
+ require 'tachain-sdk/models/model3'
53
+ require 'tachain-sdk/models/model4'
54
+ require 'tachain-sdk/models/order'
55
+ require 'tachain-sdk/models/order_api_dto'
56
+ require 'tachain-sdk/models/order_line'
57
+ require 'tachain-sdk/models/order_line_api_dto'
58
+ require 'tachain-sdk/models/order_stage_form_api_dto'
59
+ require 'tachain-sdk/models/order_stage_form_datum_api_dto'
60
+ require 'tachain-sdk/models/order_stage_form_dto'
61
+ require 'tachain-sdk/models/paged_response_delivery_note_api_dto'
62
+ require 'tachain-sdk/models/paged_response_order_api_dto'
63
+ require 'tachain-sdk/models/paged_response_production_api_dto'
64
+ require 'tachain-sdk/models/product_bom_grouping_dto'
65
+ require 'tachain-sdk/models/production_api_dto'
66
+ require 'tachain-sdk/models/production_raw_material_api_dto'
67
+ require 'tachain-sdk/models/production_raw_material_dto'
68
+ require 'tachain-sdk/models/production_sales_order_api_dto'
69
+ require 'tachain-sdk/models/result_api_enum'
70
+ require 'tachain-sdk/models/result_brand_report_allocated_delivery_kpi_detail'
71
+ require 'tachain-sdk/models/result_brand_report_unlinked_order_detail'
72
+ require 'tachain-sdk/models/result_kpi_archived_data_change_detail'
73
+ require 'tachain-sdk/models/result_mapping_order_select'
74
+ require 'tachain-sdk/models/result_order_trace_report'
75
+ require 'tachain-sdk/models/stage_attachment_api_dto'
76
+ require 'tachain-sdk/models/supplier'
77
+ require 'tachain-sdk/models/supplier_onboarding_ext'
78
+ require 'tachain-sdk/models/template_dto_business_risk_warn_info_dto'
79
+ require 'tachain-sdk/models/template_dto_multi_so_line_complete_status'
80
+ require 'tachain-sdk/models/trader'
81
+
82
+ # APIs
83
+ require 'tachain-sdk/api/api_declaration_api'
84
+ require 'tachain-sdk/api/api_delivery_api'
85
+ require 'tachain-sdk/api/api_enum_api'
86
+ require 'tachain-sdk/api/api_order_api'
87
+ require 'tachain-sdk/api/api_order_workflow_api'
88
+ require 'tachain-sdk/api/api_production_api'
89
+
90
+ module TachainSdk
91
+ class << self
92
+ # Customize default settings for the SDK using block.
93
+ # TachainSdk.configure do |config|
94
+ # config.username = "xxx"
95
+ # config.password = "xxx"
96
+ # end
97
+ # If no block given, return the default Configuration object.
98
+ def configure
99
+ if block_given?
100
+ yield(Configuration.default)
101
+ else
102
+ Configuration.default
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ require 'tachain-sdk/signed_api_client'