dear-inventory-ruby 0.1.11 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +12 -5
  4. data/docs/Customer.md +1 -1
  5. data/docs/InventoryApi.md +118 -0
  6. data/docs/Me.md +2 -2
  7. data/docs/PriceTier.md +19 -0
  8. data/docs/PriceTiers.md +17 -0
  9. data/docs/SaleInvoice.md +41 -0
  10. data/docs/SaleInvoiceAdditionalCharge.md +33 -0
  11. data/docs/SaleInvoiceLine.md +39 -0
  12. data/docs/SaleInvoices.md +19 -0
  13. data/lib/dear-inventory-ruby.rb +6 -1
  14. data/lib/dear-inventory-ruby/api/inventory_api.rb +117 -0
  15. data/lib/dear-inventory-ruby/models/customer.rb +2 -1
  16. data/lib/dear-inventory-ruby/models/me.rb +4 -2
  17. data/lib/dear-inventory-ruby/models/price_tier.rb +217 -0
  18. data/lib/dear-inventory-ruby/models/price_tiers.rb +209 -0
  19. data/lib/dear-inventory-ruby/models/sale_invoice.rb +356 -0
  20. data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +317 -0
  21. data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +342 -0
  22. data/lib/dear-inventory-ruby/models/sale_invoices.rb +224 -0
  23. data/lib/dear-inventory-ruby/version.rb +1 -1
  24. data/spec/.DS_Store +0 -0
  25. data/spec/api/inventory_api_spec.rb +23 -0
  26. data/spec/models/price_tier_spec.rb +47 -0
  27. data/spec/models/{weight_unit_spec.rb → price_tiers_spec.rb} +12 -6
  28. data/spec/models/sale_invoice_additional_charge_spec.rb +89 -0
  29. data/spec/models/sale_invoice_line_spec.rb +107 -0
  30. data/spec/models/sale_invoice_spec.rb +113 -0
  31. data/spec/models/sale_invoices_spec.rb +47 -0
  32. metadata +31 -10
  33. data/docs/WeightUnit.md +0 -16
  34. data/lib/dear-inventory-ruby/models/weight_unit.rb +0 -39
@@ -666,6 +666,123 @@ module DearInventoryRuby
666
666
  return data, status_code, headers
667
667
  end
668
668
 
669
+ # Allows you to retrieve the Price Tiers
670
+ # @param [Hash] opts the optional parameters
671
+ # @return [PriceTiers]
672
+ def get_price_tiers(opts = {})
673
+ data, _status_code, _headers = get_price_tiers_with_http_info(opts)
674
+ data
675
+ end
676
+
677
+ # Allows you to retrieve the Price Tiers
678
+ # @param [Hash] opts the optional parameters
679
+ # @return [Array<(PriceTiers, Integer, Hash)>] PriceTiers data, response status code and response headers
680
+ def get_price_tiers_with_http_info(opts = {})
681
+ if @api_client.config.debugging
682
+ @api_client.config.logger.debug 'Calling API: InventoryApi.get_price_tiers ...'
683
+ end
684
+ # resource path
685
+ local_var_path = '/ref/priceTier'
686
+
687
+ # query parameters
688
+ query_params = opts[:query_params] || {}
689
+
690
+ # header parameters
691
+ header_params = opts[:header_params] || {}
692
+ # HTTP header 'Accept' (if needed)
693
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
694
+
695
+ # form parameters
696
+ form_params = opts[:form_params] || {}
697
+
698
+ # http body (model)
699
+ post_body = opts[:body]
700
+
701
+ # return_type
702
+ return_type = opts[:return_type] || 'PriceTiers'
703
+
704
+ # auth_names
705
+ auth_names = opts[:auth_names] || ['accountID', 'appKey']
706
+
707
+ new_options = opts.merge(
708
+ :header_params => header_params,
709
+ :query_params => query_params,
710
+ :form_params => form_params,
711
+ :body => post_body,
712
+ :auth_names => auth_names,
713
+ :return_type => return_type
714
+ )
715
+
716
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
717
+ if @api_client.config.debugging
718
+ @api_client.config.logger.debug "API called: InventoryApi#get_price_tiers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
719
+ end
720
+ return data, status_code, headers
721
+ end
722
+
723
+ # Allows you to retrieve the sale invoices
724
+ # @param [Hash] opts the optional parameters
725
+ # @option opts [String] :sale_id Unique DEAR Sale ID
726
+ # @option opts [Boolean] :combine_additional_charges Show additional charges in &#39;Lines&#39; array (default to false)
727
+ # @option opts [Boolean] :include_product_info Show all used products in additional array (default to false)
728
+ # @return [SaleInvoices]
729
+ def get_sale_invoices(opts = {})
730
+ data, _status_code, _headers = get_sale_invoices_with_http_info(opts)
731
+ data
732
+ end
733
+
734
+ # Allows you to retrieve the sale invoices
735
+ # @param [Hash] opts the optional parameters
736
+ # @option opts [String] :sale_id Unique DEAR Sale ID
737
+ # @option opts [Boolean] :combine_additional_charges Show additional charges in &#39;Lines&#39; array
738
+ # @option opts [Boolean] :include_product_info Show all used products in additional array
739
+ # @return [Array<(SaleInvoices, Integer, Hash)>] SaleInvoices data, response status code and response headers
740
+ def get_sale_invoices_with_http_info(opts = {})
741
+ if @api_client.config.debugging
742
+ @api_client.config.logger.debug 'Calling API: InventoryApi.get_sale_invoices ...'
743
+ end
744
+ # resource path
745
+ local_var_path = '/sale/invoice'
746
+
747
+ # query parameters
748
+ query_params = opts[:query_params] || {}
749
+ query_params[:'SaleID'] = opts[:'sale_id'] if !opts[:'sale_id'].nil?
750
+ query_params[:'CombineAdditionalCharges'] = opts[:'combine_additional_charges'] if !opts[:'combine_additional_charges'].nil?
751
+ query_params[:'IncludeProductInfo'] = opts[:'include_product_info'] if !opts[:'include_product_info'].nil?
752
+
753
+ # header parameters
754
+ header_params = opts[:header_params] || {}
755
+ # HTTP header 'Accept' (if needed)
756
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
757
+
758
+ # form parameters
759
+ form_params = opts[:form_params] || {}
760
+
761
+ # http body (model)
762
+ post_body = opts[:body]
763
+
764
+ # return_type
765
+ return_type = opts[:return_type] || 'SaleInvoices'
766
+
767
+ # auth_names
768
+ auth_names = opts[:auth_names] || ['accountID', 'appKey']
769
+
770
+ new_options = opts.merge(
771
+ :header_params => header_params,
772
+ :query_params => query_params,
773
+ :form_params => form_params,
774
+ :body => post_body,
775
+ :auth_names => auth_names,
776
+ :return_type => return_type
777
+ )
778
+
779
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
780
+ if @api_client.config.debugging
781
+ @api_client.config.logger.debug "API called: InventoryApi#get_sale_invoices\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
782
+ end
783
+ return data, status_code, headers
784
+ end
785
+
669
786
  # Allows you to retrieve the taxes
670
787
  # @param [Hash] opts the optional parameters
671
788
  # @option opts [String] :page Default is 1 (default to '1')
@@ -23,6 +23,7 @@ module DearInventoryRuby
23
23
  # Points that Customer is Active. Available values are Active and Deprecated. Required for POST
24
24
  attr_accessor :status
25
25
 
26
+ # Currency code of Customer
26
27
  attr_accessor :currency
27
28
 
28
29
  # Payment term
@@ -175,7 +176,7 @@ module DearInventoryRuby
175
176
  :'id' => :'String',
176
177
  :'name' => :'String',
177
178
  :'status' => :'String',
178
- :'currency' => :'CurrencyCode',
179
+ :'currency' => :'String',
179
180
  :'payment_term' => :'String',
180
181
  :'account_receivable' => :'String',
181
182
  :'revenue_account' => :'String',
@@ -17,11 +17,13 @@ module DearInventoryRuby
17
17
  # Your company name
18
18
  attr_accessor :company
19
19
 
20
+ # Your company base currency
20
21
  attr_accessor :currency
21
22
 
22
23
  # Time Zone where your company located
23
24
  attr_accessor :time_zone
24
25
 
26
+ # Unit of measure for unit weight
25
27
  attr_accessor :default_weight_units
26
28
 
27
29
  attr_accessor :default_dimensions_units
@@ -49,9 +51,9 @@ module DearInventoryRuby
49
51
  def self.openapi_types
50
52
  {
51
53
  :'company' => :'String',
52
- :'currency' => :'CurrencyCode',
54
+ :'currency' => :'String',
53
55
  :'time_zone' => :'String',
54
- :'default_weight_units' => :'WeightUnit',
56
+ :'default_weight_units' => :'String',
55
57
  :'default_dimensions_units' => :'DimensionsUnit',
56
58
  :'lock_date' => :'Date',
57
59
  :'opening_balance_date' => :'Date'
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #DEAR Inventory API
3
+
4
+ #This specifing endpoints for DEAR Inventory API
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: nnhansg@gmail.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class PriceTier
17
+ # Code number of Price Tier
18
+ attr_accessor :code
19
+
20
+ # Price Tier name
21
+ attr_accessor :name
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'code' => :'Code',
27
+ :'name' => :'Name'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'code' => :'Integer',
35
+ :'name' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::PriceTier` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::PriceTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'code')
61
+ self.code = attributes[:'code']
62
+ end
63
+
64
+ if attributes.key?(:'name')
65
+ self.name = attributes[:'name']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ code == o.code &&
88
+ name == o.name
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [code, name].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ DearInventoryRuby.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,209 @@
1
+ =begin
2
+ #DEAR Inventory API
3
+
4
+ #This specifing endpoints for DEAR Inventory API
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: nnhansg@gmail.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class PriceTiers
17
+ # Array of PriceTiers
18
+ attr_accessor :price_tiers
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'price_tiers' => :'PriceTiers'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'price_tiers' => :'Array<PriceTier>'
31
+ }
32
+ end
33
+
34
+ # List of attributes with nullable: true
35
+ def self.openapi_nullable
36
+ Set.new([
37
+ ])
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::PriceTiers` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::PriceTiers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'price_tiers')
56
+ if (value = attributes[:'price_tiers']).is_a?(Array)
57
+ self.price_tiers = value
58
+ end
59
+ end
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properties with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ price_tiers == o.price_tiers
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Integer] Hash code
91
+ def hash
92
+ [price_tiers].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def self.build_from_hash(attributes)
99
+ new.build_from_hash(attributes)
100
+ end
101
+
102
+ # Builds the object from hash
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ # @return [Object] Returns the model itself
105
+ def build_from_hash(attributes)
106
+ return nil unless attributes.is_a?(Hash)
107
+ self.class.openapi_types.each_pair do |key, type|
108
+ if type =~ /\AArray<(.*)>/i
109
+ # check to ensure the input is an array given that the attribute
110
+ # is documented as an array but the input is not
111
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
112
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
113
+ end
114
+ elsif !attributes[self.class.attribute_map[key]].nil?
115
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
116
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
117
+ end
118
+
119
+ self
120
+ end
121
+
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
126
+ def _deserialize(type, value)
127
+ case type.to_sym
128
+ when :DateTime
129
+ DateTime.parse(value)
130
+ when :Date
131
+ Date.parse(value)
132
+ when :String
133
+ value.to_s
134
+ when :Integer
135
+ value.to_i
136
+ when :Float
137
+ value.to_f
138
+ when :Boolean
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
140
+ true
141
+ else
142
+ false
143
+ end
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
147
+ when /\AArray<(?<inner_type>.+)>\z/
148
+ inner_type = Regexp.last_match[:inner_type]
149
+ value.map { |v| _deserialize(inner_type, v) }
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
151
+ k_type = Regexp.last_match[:k_type]
152
+ v_type = Regexp.last_match[:v_type]
153
+ {}.tap do |hash|
154
+ value.each do |k, v|
155
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
156
+ end
157
+ end
158
+ else # model
159
+ DearInventoryRuby.const_get(type).build_from_hash(value)
160
+ end
161
+ end
162
+
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_body
172
+ to_hash
173
+ end
174
+
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_hash
178
+ hash = {}
179
+ self.class.attribute_map.each_pair do |attr, param|
180
+ value = self.send(attr)
181
+ if value.nil?
182
+ is_nullable = self.class.openapi_nullable.include?(attr)
183
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
184
+ end
185
+
186
+ hash[param] = _to_hash(value)
187
+ end
188
+ hash
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value)
196
+ if value.is_a?(Array)
197
+ value.compact.map { |v| _to_hash(v) }
198
+ elsif value.is_a?(Hash)
199
+ {}.tap do |hash|
200
+ value.each { |k, v| hash[k] = _to_hash(v) }
201
+ end
202
+ elsif value.respond_to? :to_hash
203
+ value.to_hash
204
+ else
205
+ value
206
+ end
207
+ end
208
+ end
209
+ end