apimatic-pnl-sdk 1.0.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 (172) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +164 -0
  4. data/bin/console +15 -0
  5. data/lib/postnl_ecommerce/api_helper.rb +10 -0
  6. data/lib/postnl_ecommerce/client.rb +126 -0
  7. data/lib/postnl_ecommerce/configuration.rb +195 -0
  8. data/lib/postnl_ecommerce/controllers/barcode_controller.rb +71 -0
  9. data/lib/postnl_ecommerce/controllers/base_controller.rb +60 -0
  10. data/lib/postnl_ecommerce/controllers/checkout_controller.rb +45 -0
  11. data/lib/postnl_ecommerce/controllers/confirming_controller.rb +45 -0
  12. data/lib/postnl_ecommerce/controllers/deliverydate_controller.rb +233 -0
  13. data/lib/postnl_ecommerce/controllers/labelling_controller.rb +52 -0
  14. data/lib/postnl_ecommerce/controllers/locations_controller.rb +271 -0
  15. data/lib/postnl_ecommerce/controllers/postalcode_check_controller.rb +60 -0
  16. data/lib/postnl_ecommerce/controllers/shipment_controller.rb +52 -0
  17. data/lib/postnl_ecommerce/controllers/shipping_status_controller.rb +222 -0
  18. data/lib/postnl_ecommerce/controllers/timeframes_controller.rb +90 -0
  19. data/lib/postnl_ecommerce/exceptions/api_exception.rb +21 -0
  20. data/lib/postnl_ecommerce/exceptions/barcode_response_invalid_exception.rb +57 -0
  21. data/lib/postnl_ecommerce/exceptions/confirming_response_error_exception.rb +55 -0
  22. data/lib/postnl_ecommerce/exceptions/internal_server_error_exception.rb +46 -0
  23. data/lib/postnl_ecommerce/exceptions/invalid_request_exception.rb +62 -0
  24. data/lib/postnl_ecommerce/exceptions/labelling_response_invalid_exception.rb +57 -0
  25. data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_get_exception.rb +53 -0
  26. data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_get_post_exception.rb +53 -0
  27. data/lib/postnl_ecommerce/exceptions/method_not_allowed_only_post_exception.rb +53 -0
  28. data/lib/postnl_ecommerce/exceptions/postalcode_check_response_invalid_exception.rb +55 -0
  29. data/lib/postnl_ecommerce/exceptions/too_many_requests_exception.rb +53 -0
  30. data/lib/postnl_ecommerce/exceptions/unauthorized_exception.rb +53 -0
  31. data/lib/postnl_ecommerce/http/api_response.rb +19 -0
  32. data/lib/postnl_ecommerce/http/auth/custom_header_authentication.rb +52 -0
  33. data/lib/postnl_ecommerce/http/http_call_back.rb +10 -0
  34. data/lib/postnl_ecommerce/http/http_method_enum.rb +10 -0
  35. data/lib/postnl_ecommerce/http/http_request.rb +10 -0
  36. data/lib/postnl_ecommerce/http/http_response.rb +10 -0
  37. data/lib/postnl_ecommerce/http/proxy_settings.rb +22 -0
  38. data/lib/postnl_ecommerce/models/address.rb +240 -0
  39. data/lib/postnl_ecommerce/models/address_type_enum.rb +36 -0
  40. data/lib/postnl_ecommerce/models/amount.rb +138 -0
  41. data/lib/postnl_ecommerce/models/barcode_error.rb +71 -0
  42. data/lib/postnl_ecommerce/models/barcode_response.rb +62 -0
  43. data/lib/postnl_ecommerce/models/base_model.rb +110 -0
  44. data/lib/postnl_ecommerce/models/checkout_address.rb +120 -0
  45. data/lib/postnl_ecommerce/models/checkout_cut_off_day_enum.rb +61 -0
  46. data/lib/postnl_ecommerce/models/checkout_cut_off_time.rb +91 -0
  47. data/lib/postnl_ecommerce/models/checkout_cut_off_type_enum.rb +40 -0
  48. data/lib/postnl_ecommerce/models/checkout_delivery_option.rb +81 -0
  49. data/lib/postnl_ecommerce/models/checkout_location.rb +126 -0
  50. data/lib/postnl_ecommerce/models/checkout_option_enum.rb +64 -0
  51. data/lib/postnl_ecommerce/models/checkout_pickup_address.rb +112 -0
  52. data/lib/postnl_ecommerce/models/checkout_pickup_option.rb +103 -0
  53. data/lib/postnl_ecommerce/models/checkout_request.rb +152 -0
  54. data/lib/postnl_ecommerce/models/checkout_response.rb +110 -0
  55. data/lib/postnl_ecommerce/models/checkout_time_frame.rb +108 -0
  56. data/lib/postnl_ecommerce/models/checkout_warning.rb +95 -0
  57. data/lib/postnl_ecommerce/models/checkout_warning_option_enum.rb +68 -0
  58. data/lib/postnl_ecommerce/models/code_enum.rb +44 -0
  59. data/lib/postnl_ecommerce/models/complete_status.rb +62 -0
  60. data/lib/postnl_ecommerce/models/complete_status_shipment.rb +270 -0
  61. data/lib/postnl_ecommerce/models/confirming_custom.rb +239 -0
  62. data/lib/postnl_ecommerce/models/confirming_custom_content.rb +113 -0
  63. data/lib/postnl_ecommerce/models/confirming_error.rb +71 -0
  64. data/lib/postnl_ecommerce/models/confirming_message.rb +70 -0
  65. data/lib/postnl_ecommerce/models/confirming_request.rb +86 -0
  66. data/lib/postnl_ecommerce/models/confirming_response.rb +71 -0
  67. data/lib/postnl_ecommerce/models/confirming_response_shipment.rb +103 -0
  68. data/lib/postnl_ecommerce/models/confirming_shipment.rb +472 -0
  69. data/lib/postnl_ecommerce/models/contact.rb +101 -0
  70. data/lib/postnl_ecommerce/models/countrycode_enum.rb +36 -0
  71. data/lib/postnl_ecommerce/models/currency_enum.rb +44 -0
  72. data/lib/postnl_ecommerce/models/currency_labelling_api_enum.rb +36 -0
  73. data/lib/postnl_ecommerce/models/current_status.rb +62 -0
  74. data/lib/postnl_ecommerce/models/current_status_shipment.rb +207 -0
  75. data/lib/postnl_ecommerce/models/customer.rb +123 -0
  76. data/lib/postnl_ecommerce/models/customer_address.rb +237 -0
  77. data/lib/postnl_ecommerce/models/customs.rb +238 -0
  78. data/lib/postnl_ecommerce/models/customs_labelling_api.rb +238 -0
  79. data/lib/postnl_ecommerce/models/delivery_options.rb +64 -0
  80. data/lib/postnl_ecommerce/models/deliverydate_delivery_response.rb +87 -0
  81. data/lib/postnl_ecommerce/models/deliverydate_option_enum.rb +56 -0
  82. data/lib/postnl_ecommerce/models/deliverydate_options.rb +65 -0
  83. data/lib/postnl_ecommerce/models/deliverydate_shipping_response.rb +62 -0
  84. data/lib/postnl_ecommerce/models/detail.rb +62 -0
  85. data/lib/postnl_ecommerce/models/dimension.rb +106 -0
  86. data/lib/postnl_ecommerce/models/error.rb +73 -0
  87. data/lib/postnl_ecommerce/models/event.rb +127 -0
  88. data/lib/postnl_ecommerce/models/expectation.rb +71 -0
  89. data/lib/postnl_ecommerce/models/extra_field.rb +71 -0
  90. data/lib/postnl_ecommerce/models/fault.rb +71 -0
  91. data/lib/postnl_ecommerce/models/fault_shipping_status_api.rb +71 -0
  92. data/lib/postnl_ecommerce/models/friday.rb +62 -0
  93. data/lib/postnl_ecommerce/models/get_locations_result_multiple.rb +71 -0
  94. data/lib/postnl_ecommerce/models/get_locations_result_single.rb +62 -0
  95. data/lib/postnl_ecommerce/models/group.rb +97 -0
  96. data/lib/postnl_ecommerce/models/hazardous_material.rb +178 -0
  97. data/lib/postnl_ecommerce/models/labelling_customer.rb +123 -0
  98. data/lib/postnl_ecommerce/models/labelling_customer_labelling_api.rb +123 -0
  99. data/lib/postnl_ecommerce/models/labelling_customer_message.rb +83 -0
  100. data/lib/postnl_ecommerce/models/labelling_customer_shipment.rb +484 -0
  101. data/lib/postnl_ecommerce/models/labelling_customer_shipment_labelling_api.rb +484 -0
  102. data/lib/postnl_ecommerce/models/labelling_customs_content.rb +111 -0
  103. data/lib/postnl_ecommerce/models/labelling_error.rb +81 -0
  104. data/lib/postnl_ecommerce/models/labelling_label.rb +84 -0
  105. data/lib/postnl_ecommerce/models/labelling_merged_label.rb +80 -0
  106. data/lib/postnl_ecommerce/models/labelling_request.rb +112 -0
  107. data/lib/postnl_ecommerce/models/labelling_response.rb +95 -0
  108. data/lib/postnl_ecommerce/models/labelling_response_shipment.rb +123 -0
  109. data/lib/postnl_ecommerce/models/language_enum.rb +48 -0
  110. data/lib/postnl_ecommerce/models/location.rb +174 -0
  111. data/lib/postnl_ecommerce/models/location_response_single.rb +63 -0
  112. data/lib/postnl_ecommerce/models/locations_address.rb +122 -0
  113. data/lib/postnl_ecommerce/models/locations_delivery_option_enum.rb +40 -0
  114. data/lib/postnl_ecommerce/models/locations_opening_hours.rb +121 -0
  115. data/lib/postnl_ecommerce/models/locations_response_multiple.rb +63 -0
  116. data/lib/postnl_ecommerce/models/monday.rb +62 -0
  117. data/lib/postnl_ecommerce/models/no_timeframes_options.rb +62 -0
  118. data/lib/postnl_ecommerce/models/old_status.rb +106 -0
  119. data/lib/postnl_ecommerce/models/opening_hours.rb +121 -0
  120. data/lib/postnl_ecommerce/models/opening_hours_per_day.rb +71 -0
  121. data/lib/postnl_ecommerce/models/options.rb +64 -0
  122. data/lib/postnl_ecommerce/models/origin_country_code_enum.rb +36 -0
  123. data/lib/postnl_ecommerce/models/postalcode_check_address.rb +116 -0
  124. data/lib/postnl_ecommerce/models/postalcode_check_error.rb +81 -0
  125. data/lib/postnl_ecommerce/models/product_option.rb +74 -0
  126. data/lib/postnl_ecommerce/models/reason_no_timeframe.rb +104 -0
  127. data/lib/postnl_ecommerce/models/reason_no_timeframes.rb +71 -0
  128. data/lib/postnl_ecommerce/models/saturday.rb +62 -0
  129. data/lib/postnl_ecommerce/models/shipment_type_enum.rb +50 -0
  130. data/lib/postnl_ecommerce/models/shippingstatus_address.rb +204 -0
  131. data/lib/postnl_ecommerce/models/shippingstatus_amount.rb +75 -0
  132. data/lib/postnl_ecommerce/models/shippingstatus_customer.rb +83 -0
  133. data/lib/postnl_ecommerce/models/shippingstatus_dimension.rb +101 -0
  134. data/lib/postnl_ecommerce/models/shippingstatus_product_option.rb +74 -0
  135. data/lib/postnl_ecommerce/models/shippingstatus_product_options.rb +63 -0
  136. data/lib/postnl_ecommerce/models/shippingstatus_response.rb +94 -0
  137. data/lib/postnl_ecommerce/models/shippingstatus_response_signature.rb +71 -0
  138. data/lib/postnl_ecommerce/models/shippingstatus_response_updated_shipment.rb +105 -0
  139. data/lib/postnl_ecommerce/models/shippingstatus_warning.rb +71 -0
  140. data/lib/postnl_ecommerce/models/signature.rb +84 -0
  141. data/lib/postnl_ecommerce/models/status.rb +108 -0
  142. data/lib/postnl_ecommerce/models/sunday.rb +62 -0
  143. data/lib/postnl_ecommerce/models/sustainability.rb +73 -0
  144. data/lib/postnl_ecommerce/models/thursday.rb +62 -0
  145. data/lib/postnl_ecommerce/models/timeframe.rb +71 -0
  146. data/lib/postnl_ecommerce/models/timeframe_options_enum.rb +60 -0
  147. data/lib/postnl_ecommerce/models/timeframe_response.rb +74 -0
  148. data/lib/postnl_ecommerce/models/timeframe_timeframe.rb +96 -0
  149. data/lib/postnl_ecommerce/models/timeframes.rb +71 -0
  150. data/lib/postnl_ecommerce/models/timeframes_response_object.rb +71 -0
  151. data/lib/postnl_ecommerce/models/tuesday.rb +62 -0
  152. data/lib/postnl_ecommerce/models/type_enum.rb +64 -0
  153. data/lib/postnl_ecommerce/models/updated_shipment_status.rb +108 -0
  154. data/lib/postnl_ecommerce/models/warning.rb +71 -0
  155. data/lib/postnl_ecommerce/models/warnings.rb +62 -0
  156. data/lib/postnl_ecommerce/models/wednesday.rb +62 -0
  157. data/lib/postnl_ecommerce/utilities/date_time_helper.rb +11 -0
  158. data/lib/postnl_ecommerce/utilities/file_wrapper.rb +28 -0
  159. data/lib/postnl_ecommerce.rb +188 -0
  160. data/test/controllers/controller_test_base.rb +23 -0
  161. data/test/controllers/test_barcode_controller.rb +52 -0
  162. data/test/controllers/test_checkout_controller.rb +63 -0
  163. data/test/controllers/test_confirming_controller.rb +54 -0
  164. data/test/controllers/test_deliverydate_controller.rb +60 -0
  165. data/test/controllers/test_labelling_controller.rb +57 -0
  166. data/test/controllers/test_locations_controller.rb +185 -0
  167. data/test/controllers/test_postalcode_check_controller.rb +55 -0
  168. data/test/controllers/test_shipment_controller.rb +57 -0
  169. data/test/controllers/test_shipping_status_controller.rb +209 -0
  170. data/test/controllers/test_timeframes_controller.rb +67 -0
  171. data/test/http_response_catcher.rb +19 -0
  172. metadata +283 -0
@@ -0,0 +1,84 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # LabellingLabel Model.
8
+ class LabellingLabel < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Base64 encoded label content
13
+ # @return [String]
14
+ attr_accessor :content
15
+
16
+ # Type of the label. See possible [Label
17
+ # types](https://developer.postnl.nl/docs/#/http/reference-data/reference-co
18
+ # des/label-types)
19
+ # @return [String]
20
+ attr_accessor :labeltype
21
+
22
+ # Content type of the label, e.g. zebra of pdf.
23
+ # @return [String]
24
+ attr_accessor :output_type
25
+
26
+ # A mapping from model property names to API property names.
27
+ def self.names
28
+ @_hash = {} if @_hash.nil?
29
+ @_hash['content'] = 'Content'
30
+ @_hash['labeltype'] = 'Labeltype'
31
+ @_hash['output_type'] = 'OutputType'
32
+ @_hash
33
+ end
34
+
35
+ # An array for optional fields
36
+ def self.optionals
37
+ %w[
38
+ content
39
+ labeltype
40
+ output_type
41
+ ]
42
+ end
43
+
44
+ # An array for nullable fields
45
+ def self.nullables
46
+ []
47
+ end
48
+
49
+ def initialize(content = SKIP, labeltype = SKIP, output_type = SKIP)
50
+ @content = content unless content == SKIP
51
+ @labeltype = labeltype unless labeltype == SKIP
52
+ @output_type = output_type unless output_type == SKIP
53
+ end
54
+
55
+ # Creates an instance of the object from a hash.
56
+ def self.from_hash(hash)
57
+ return nil unless hash
58
+
59
+ # Extract variables from the hash.
60
+ content = hash.key?('Content') ? hash['Content'] : SKIP
61
+ labeltype = hash.key?('Labeltype') ? hash['Labeltype'] : SKIP
62
+ output_type = hash.key?('OutputType') ? hash['OutputType'] : SKIP
63
+
64
+ # Create object from extracted values.
65
+ LabellingLabel.new(content,
66
+ labeltype,
67
+ output_type)
68
+ end
69
+
70
+ # Provides a human-readable string representation of the object.
71
+ def to_s
72
+ class_name = self.class.name.split('::').last
73
+ "<#{class_name} content: #{@content}, labeltype: #{@labeltype}, output_type:"\
74
+ " #{@output_type}>"
75
+ end
76
+
77
+ # Provides a debugging-friendly string with detailed object information.
78
+ def inspect
79
+ class_name = self.class.name.split('::').last
80
+ "<#{class_name} content: #{@content.inspect}, labeltype: #{@labeltype.inspect},"\
81
+ " output_type: #{@output_type.inspect}>"
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,80 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # LabellingMergedLabel Model.
8
+ class LabellingMergedLabel < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Array[String]]
14
+ attr_accessor :barcodes
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [Array[LabellingLabel]]
18
+ attr_accessor :labels
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['barcodes'] = 'Barcodes'
24
+ @_hash['labels'] = 'Labels'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ %w[
31
+ barcodes
32
+ labels
33
+ ]
34
+ end
35
+
36
+ # An array for nullable fields
37
+ def self.nullables
38
+ []
39
+ end
40
+
41
+ def initialize(barcodes = SKIP, labels = SKIP)
42
+ @barcodes = barcodes unless barcodes == SKIP
43
+ @labels = labels unless labels == SKIP
44
+ end
45
+
46
+ # Creates an instance of the object from a hash.
47
+ def self.from_hash(hash)
48
+ return nil unless hash
49
+
50
+ # Extract variables from the hash.
51
+ barcodes = hash.key?('Barcodes') ? hash['Barcodes'] : SKIP
52
+ # Parameter is an array, so we need to iterate through it
53
+ labels = nil
54
+ unless hash['Labels'].nil?
55
+ labels = []
56
+ hash['Labels'].each do |structure|
57
+ labels << (LabellingLabel.from_hash(structure) if structure)
58
+ end
59
+ end
60
+
61
+ labels = SKIP unless hash.key?('Labels')
62
+
63
+ # Create object from extracted values.
64
+ LabellingMergedLabel.new(barcodes,
65
+ labels)
66
+ end
67
+
68
+ # Provides a human-readable string representation of the object.
69
+ def to_s
70
+ class_name = self.class.name.split('::').last
71
+ "<#{class_name} barcodes: #{@barcodes}, labels: #{@labels}>"
72
+ end
73
+
74
+ # Provides a debugging-friendly string with detailed object information.
75
+ def inspect
76
+ class_name = self.class.name.split('::').last
77
+ "<#{class_name} barcodes: #{@barcodes.inspect}, labels: #{@labels.inspect}>"
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,112 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # LabellingRequest Model.
8
+ class LabellingRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [LabellingCustomer]
14
+ attr_accessor :customer
15
+
16
+ # GIF image of the signature (as a base64 encoded string) max size: 280x60
17
+ # mm (1058x226 pixels). This can be used to automatically sign the customs
18
+ # forms. The value of this element can have a maximum size of 65536
19
+ # characters. Note that the total request can have a maximum size of 200KB.
20
+ # Larger requests will not be accepted by the server for performance
21
+ # reasons. Requests that exceed this limit will not return a validation
22
+ # error,but a HTTP 404 error.
23
+ # @return [String]
24
+ attr_accessor :label_signature
25
+
26
+ # GIF image of the signature (as a base64 encoded string) max size: 280x60
27
+ # mm (1058x226 pixels). This can be used to automatically sign the customs
28
+ # forms. The value of this element can have a maximum size of 65536
29
+ # characters. Note that the total request can have a maximum size of 200KB.
30
+ # Larger requests will not be accepted by the server for performance
31
+ # reasons. Requests that exceed this limit will not return a validation
32
+ # error,but a HTTP 404 error.
33
+ # @return [LabellingCustomerMessage]
34
+ attr_accessor :message
35
+
36
+ # List of 1 or more Shipments. At least 1 shipment is required.
37
+ # @return [Array[LabellingCustomerShipment]]
38
+ attr_accessor :shipments
39
+
40
+ # A mapping from model property names to API property names.
41
+ def self.names
42
+ @_hash = {} if @_hash.nil?
43
+ @_hash['customer'] = 'Customer'
44
+ @_hash['label_signature'] = 'LabelSignature'
45
+ @_hash['message'] = 'Message'
46
+ @_hash['shipments'] = 'Shipments'
47
+ @_hash
48
+ end
49
+
50
+ # An array for optional fields
51
+ def self.optionals
52
+ %w[
53
+ label_signature
54
+ ]
55
+ end
56
+
57
+ # An array for nullable fields
58
+ def self.nullables
59
+ []
60
+ end
61
+
62
+ def initialize(customer = nil, message = nil, shipments = nil,
63
+ label_signature = SKIP)
64
+ @customer = customer
65
+ @label_signature = label_signature unless label_signature == SKIP
66
+ @message = message
67
+ @shipments = shipments
68
+ end
69
+
70
+ # Creates an instance of the object from a hash.
71
+ def self.from_hash(hash)
72
+ return nil unless hash
73
+
74
+ # Extract variables from the hash.
75
+ customer = LabellingCustomer.from_hash(hash['Customer']) if hash['Customer']
76
+ message = LabellingCustomerMessage.from_hash(hash['Message']) if hash['Message']
77
+ # Parameter is an array, so we need to iterate through it
78
+ shipments = nil
79
+ unless hash['Shipments'].nil?
80
+ shipments = []
81
+ hash['Shipments'].each do |structure|
82
+ shipments << (LabellingCustomerShipment.from_hash(structure) if structure)
83
+ end
84
+ end
85
+
86
+ shipments = nil unless hash.key?('Shipments')
87
+ label_signature =
88
+ hash.key?('LabelSignature') ? hash['LabelSignature'] : SKIP
89
+
90
+ # Create object from extracted values.
91
+ LabellingRequest.new(customer,
92
+ message,
93
+ shipments,
94
+ label_signature)
95
+ end
96
+
97
+ # Provides a human-readable string representation of the object.
98
+ def to_s
99
+ class_name = self.class.name.split('::').last
100
+ "<#{class_name} customer: #{@customer}, label_signature: #{@label_signature}, message:"\
101
+ " #{@message}, shipments: #{@shipments}>"
102
+ end
103
+
104
+ # Provides a debugging-friendly string with detailed object information.
105
+ def inspect
106
+ class_name = self.class.name.split('::').last
107
+ "<#{class_name} customer: #{@customer.inspect}, label_signature:"\
108
+ " #{@label_signature.inspect}, message: #{@message.inspect}, shipments:"\
109
+ " #{@shipments.inspect}>"
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,95 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # LabellingResponse Model.
8
+ class LabellingResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The merged label output; only returned if the printer type selected in
13
+ # your request merges the pdf labels into a single file (e.g. using
14
+ # GraphicFile|Merge).
15
+ # @return [Array[LabellingMergedLabel]]
16
+ attr_accessor :merged_labels
17
+
18
+ # The merged label output; only returned if the printer type selected in
19
+ # your request merges the pdf labels into a single file (e.g. using
20
+ # GraphicFile|Merge).
21
+ # @return [Array[LabellingResponseShipment]]
22
+ attr_accessor :response_shipments
23
+
24
+ # A mapping from model property names to API property names.
25
+ def self.names
26
+ @_hash = {} if @_hash.nil?
27
+ @_hash['merged_labels'] = 'MergedLabels'
28
+ @_hash['response_shipments'] = 'ResponseShipments'
29
+ @_hash
30
+ end
31
+
32
+ # An array for optional fields
33
+ def self.optionals
34
+ %w[
35
+ merged_labels
36
+ response_shipments
37
+ ]
38
+ end
39
+
40
+ # An array for nullable fields
41
+ def self.nullables
42
+ []
43
+ end
44
+
45
+ def initialize(merged_labels = SKIP, response_shipments = SKIP)
46
+ @merged_labels = merged_labels unless merged_labels == SKIP
47
+ @response_shipments = response_shipments unless response_shipments == SKIP
48
+ end
49
+
50
+ # Creates an instance of the object from a hash.
51
+ def self.from_hash(hash)
52
+ return nil unless hash
53
+
54
+ # Extract variables from the hash.
55
+ # Parameter is an array, so we need to iterate through it
56
+ merged_labels = nil
57
+ unless hash['MergedLabels'].nil?
58
+ merged_labels = []
59
+ hash['MergedLabels'].each do |structure|
60
+ merged_labels << (LabellingMergedLabel.from_hash(structure) if structure)
61
+ end
62
+ end
63
+
64
+ merged_labels = SKIP unless hash.key?('MergedLabels')
65
+ # Parameter is an array, so we need to iterate through it
66
+ response_shipments = nil
67
+ unless hash['ResponseShipments'].nil?
68
+ response_shipments = []
69
+ hash['ResponseShipments'].each do |structure|
70
+ response_shipments << (LabellingResponseShipment.from_hash(structure) if structure)
71
+ end
72
+ end
73
+
74
+ response_shipments = SKIP unless hash.key?('ResponseShipments')
75
+
76
+ # Create object from extracted values.
77
+ LabellingResponse.new(merged_labels,
78
+ response_shipments)
79
+ end
80
+
81
+ # Provides a human-readable string representation of the object.
82
+ def to_s
83
+ class_name = self.class.name.split('::').last
84
+ "<#{class_name} merged_labels: #{@merged_labels}, response_shipments:"\
85
+ " #{@response_shipments}>"
86
+ end
87
+
88
+ # Provides a debugging-friendly string with detailed object information.
89
+ def inspect
90
+ class_name = self.class.name.split('::').last
91
+ "<#{class_name} merged_labels: #{@merged_labels.inspect}, response_shipments:"\
92
+ " #{@response_shipments.inspect}>"
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,123 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # LabellingResponseShipment Model.
8
+ class LabellingResponseShipment < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The product code of the shipment
13
+ # @return [String]
14
+ attr_accessor :product_code_delivery
15
+
16
+ # All labels belonging to the selected product
17
+ # @return [Array[LabellingLabel]]
18
+ attr_accessor :labels
19
+
20
+ # The barcode used on the label
21
+ # @return [String]
22
+ attr_accessor :barcode
23
+
24
+ # The barcode used on the label
25
+ # @return [Array[Object]]
26
+ attr_accessor :errors
27
+
28
+ # Possible warnings. See the [Error
29
+ # Codes](https://developer.postnl.nl/docs/#/http/reference-data/error-codes)
30
+ # for possible values
31
+ # @return [Array[Warning]]
32
+ attr_accessor :warnings
33
+
34
+ # A mapping from model property names to API property names.
35
+ def self.names
36
+ @_hash = {} if @_hash.nil?
37
+ @_hash['product_code_delivery'] = 'ProductCodeDelivery'
38
+ @_hash['labels'] = 'Labels'
39
+ @_hash['barcode'] = 'Barcode'
40
+ @_hash['errors'] = 'Errors'
41
+ @_hash['warnings'] = 'Warnings'
42
+ @_hash
43
+ end
44
+
45
+ # An array for optional fields
46
+ def self.optionals
47
+ %w[
48
+ product_code_delivery
49
+ labels
50
+ barcode
51
+ errors
52
+ warnings
53
+ ]
54
+ end
55
+
56
+ # An array for nullable fields
57
+ def self.nullables
58
+ []
59
+ end
60
+
61
+ def initialize(product_code_delivery = SKIP, labels = SKIP, barcode = SKIP,
62
+ errors = SKIP, warnings = SKIP)
63
+ @product_code_delivery = product_code_delivery unless product_code_delivery == SKIP
64
+ @labels = labels unless labels == SKIP
65
+ @barcode = barcode unless barcode == SKIP
66
+ @errors = errors unless errors == SKIP
67
+ @warnings = warnings unless warnings == SKIP
68
+ end
69
+
70
+ # Creates an instance of the object from a hash.
71
+ def self.from_hash(hash)
72
+ return nil unless hash
73
+
74
+ # Extract variables from the hash.
75
+ product_code_delivery =
76
+ hash.key?('ProductCodeDelivery') ? hash['ProductCodeDelivery'] : SKIP
77
+ # Parameter is an array, so we need to iterate through it
78
+ labels = nil
79
+ unless hash['Labels'].nil?
80
+ labels = []
81
+ hash['Labels'].each do |structure|
82
+ labels << (LabellingLabel.from_hash(structure) if structure)
83
+ end
84
+ end
85
+
86
+ labels = SKIP unless hash.key?('Labels')
87
+ barcode = hash.key?('Barcode') ? hash['Barcode'] : SKIP
88
+ errors = hash.key?('Errors') ? hash['Errors'] : SKIP
89
+ # Parameter is an array, so we need to iterate through it
90
+ warnings = nil
91
+ unless hash['Warnings'].nil?
92
+ warnings = []
93
+ hash['Warnings'].each do |structure|
94
+ warnings << (Warning.from_hash(structure) if structure)
95
+ end
96
+ end
97
+
98
+ warnings = SKIP unless hash.key?('Warnings')
99
+
100
+ # Create object from extracted values.
101
+ LabellingResponseShipment.new(product_code_delivery,
102
+ labels,
103
+ barcode,
104
+ errors,
105
+ warnings)
106
+ end
107
+
108
+ # Provides a human-readable string representation of the object.
109
+ def to_s
110
+ class_name = self.class.name.split('::').last
111
+ "<#{class_name} product_code_delivery: #{@product_code_delivery}, labels: #{@labels},"\
112
+ " barcode: #{@barcode}, errors: #{@errors}, warnings: #{@warnings}>"
113
+ end
114
+
115
+ # Provides a debugging-friendly string with detailed object information.
116
+ def inspect
117
+ class_name = self.class.name.split('::').last
118
+ "<#{class_name} product_code_delivery: #{@product_code_delivery.inspect}, labels:"\
119
+ " #{@labels.inspect}, barcode: #{@barcode.inspect}, errors: #{@errors.inspect}, warnings:"\
120
+ " #{@warnings.inspect}>"
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,48 @@
1
+ # postnl_ecommerce
2
+ #
3
+ # This file was automatically generated for PostNL by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module PostnlEcommerce
7
+ # language.
8
+ class LanguageEnum
9
+ LANGUAGE_ENUM = [
10
+ # TODO: Write general description for NL
11
+ NL = 'NL'.freeze,
12
+
13
+ # TODO: Write general description for EN
14
+ EN = 'EN'.freeze,
15
+
16
+ # TODO: Write general description for CN
17
+ CN = 'CN'.freeze,
18
+
19
+ # TODO: Write general description for DE
20
+ DE = 'DE'.freeze,
21
+
22
+ # TODO: Write general description for FR
23
+ FR = 'FR'.freeze
24
+ ].freeze
25
+
26
+ def self.validate(value)
27
+ return false if value.nil?
28
+
29
+ LANGUAGE_ENUM.include?(value)
30
+ end
31
+
32
+ def self.from_value(value, default_value = NL)
33
+ return default_value if value.nil?
34
+
35
+ str = value.to_s.strip
36
+
37
+ case str.downcase
38
+ when 'nl' then NL
39
+ when 'en' then EN
40
+ when 'cn' then CN
41
+ when 'de' then DE
42
+ when 'fr' then FR
43
+ else
44
+ default_value
45
+ end
46
+ end
47
+ end
48
+ end