patch_ruby 1.17.1 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01aa479a3dfd04193fba725fe8f26d0cb4754ed829dcd55824fe34c9b2b3e608
4
- data.tar.gz: bf650d916330ce6be13d0794c802b916ba67d9b1867e1a02e4730537c219bb45
3
+ metadata.gz: 3312ae1bca095a1ee4b912f2267748f57818ef9be2c10febd7bf5f8095bf15a4
4
+ data.tar.gz: dc08f9414555d65f420a2b8bae74a44c582b15a9702f40bd1e8a875cb094d637
5
5
  SHA512:
6
- metadata.gz: 147ff1b520b0629f9e0c293a386a695fc33a77fbbd22149006046e9de8d204cf1891e8631d897d64b83004b79fef9931ba7461a850b5831a4522feec211285fb
7
- data.tar.gz: e2a1cf40776a588973f778fd73ebe1699e4b0ee767dce56d704aa788a8cc6ae54d50ecd484c303862ef4cd73556c731fa66e204429fd1d500547c845eef13995
6
+ metadata.gz: fdf4400660c261231c72654cdead5108cfe90ff6d02457b9057ae7bb8537c55f19e2edb7004604b5d9a39474d5da9222bc8ffded005e808b0c0ab718186eec15
7
+ data.tar.gz: 4680eafea0b29e4eef4a8e393c56d4b0c9ad12828fa255535035e5fa786a86ef5237cfe0bb715270e3a2b376241d2e42294eb36444da17e17452d7e606d218f9
data/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.18.0] - 2022-03-22
9
+ ### Changed
10
+
11
+ - Adds optional `state` field to `order` creation
12
+
8
13
  ## [1.17.0] - 2022-01-11
9
14
 
10
15
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.17.1)
4
+ patch_ruby (1.18.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -92,7 +92,7 @@ module Patch
92
92
  end
93
93
 
94
94
  # Creates an order
95
- # Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
95
+ # Creates an order in the `placed` or `draft` state.
96
96
  # @param create_order_request [CreateOrderRequest]
97
97
  # @param [Hash] opts the optional parameters
98
98
  # @return [OrderResponse]
@@ -103,7 +103,7 @@ module Patch
103
103
  end
104
104
 
105
105
  # Creates an order
106
- # Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
106
+ # Creates an order in the `placed` or `draft` state.
107
107
  # @param create_order_request [CreateOrderRequest]
108
108
  # @param [Hash] opts the optional parameters
109
109
  # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
@@ -31,7 +31,7 @@ module Patch
31
31
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
32
  def initialize(config = Configuration.default)
33
33
  @config = config
34
- @user_agent = "patch-ruby/1.17.1"
34
+ @user_agent = "patch-ruby/1.18.0"
35
35
  @default_headers = {
36
36
  'Content-Type' => 'application/json',
37
37
  'User-Agent' => @user_agent
@@ -23,13 +23,38 @@ module Patch
23
23
 
24
24
  attr_accessor :metadata
25
25
 
26
+ attr_accessor :state
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
26
50
  # Attribute mapping from ruby-style variable name to JSON key.
27
51
  def self.attribute_map
28
52
  {
29
53
  :'mass_g' => :'mass_g',
30
54
  :'total_price_cents_usd' => :'total_price_cents_usd',
31
55
  :'project_id' => :'project_id',
32
- :'metadata' => :'metadata'
56
+ :'metadata' => :'metadata',
57
+ :'state' => :'state'
33
58
  }
34
59
  end
35
60
 
@@ -44,7 +69,8 @@ module Patch
44
69
  :'mass_g' => :'Integer',
45
70
  :'total_price_cents_usd' => :'Integer',
46
71
  :'project_id' => :'String',
47
- :'metadata' => :'Object'
72
+ :'metadata' => :'Object',
73
+ :'state' => :'String'
48
74
  }
49
75
  end
50
76
 
@@ -96,6 +122,10 @@ module Patch
96
122
  if attributes.key?(:'metadata')
97
123
  self.metadata = attributes[:'metadata']
98
124
  end
125
+
126
+ if attributes.key?(:'state')
127
+ self.state = attributes[:'state']
128
+ end
99
129
  end
100
130
 
101
131
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -123,6 +153,8 @@ module Patch
123
153
  return false if !@mass_g.nil? && @mass_g > 100000000000
124
154
  return false if !@mass_g.nil? && @mass_g < 0
125
155
  return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
156
+ state_validator = EnumAttributeValidator.new('String', ["draft", "placed"])
157
+ return false unless state_validator.valid?(@state)
126
158
  true
127
159
  end
128
160
 
@@ -150,6 +182,16 @@ module Patch
150
182
  @total_price_cents_usd = total_price_cents_usd
151
183
  end
152
184
 
185
+ # Custom attribute writer method checking allowed values (enum).
186
+ # @param [Object] state Object to be assigned
187
+ def state=(state)
188
+ validator = EnumAttributeValidator.new('String', ["draft", "placed"])
189
+ unless validator.valid?(state)
190
+ fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
191
+ end
192
+ @state = state
193
+ end
194
+
153
195
  # Checks equality by comparing each attribute.
154
196
  # @param [Object] Object to be compared
155
197
  def ==(o)
@@ -158,7 +200,8 @@ module Patch
158
200
  mass_g == o.mass_g &&
159
201
  total_price_cents_usd == o.total_price_cents_usd &&
160
202
  project_id == o.project_id &&
161
- metadata == o.metadata
203
+ metadata == o.metadata &&
204
+ state == o.state
162
205
  end
163
206
 
164
207
  # @see the `==` method
@@ -170,7 +213,7 @@ module Patch
170
213
  # Calculates hash code according to all attributes.
171
214
  # @return [Integer] Hash code
172
215
  def hash
173
- [mass_g, total_price_cents_usd, project_id, metadata].hash
216
+ [mass_g, total_price_cents_usd, project_id, metadata, state].hash
174
217
  end
175
218
 
176
219
  # Builds the object from hash
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.17.1'
14
+ VERSION = '1.18.0'
15
15
  end
@@ -84,7 +84,17 @@ RSpec.describe 'Orders Integration' do
84
84
  .to all(have_key(:user))
85
85
  end
86
86
 
87
- it 'supports place and cancel for orders created via an estimate' do
87
+ it 'supports creation in draft state' do
88
+ create_order_response =
89
+ Patch::Order.create_order(mass_g: 100, state: "draft")
90
+
91
+ expect(create_order_response.success).to eq true
92
+ expect(create_order_response.data.id).not_to be_nil
93
+ expect(create_order_response.data.mass_g).to eq(100)
94
+ expect(create_order_response.data.state).to eq("draft")
95
+ end
96
+
97
+ xit 'supports place and cancel for orders created via an estimate' do
88
98
  create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true)
89
99
  order_to_place_id = create_estimate_to_place_response.data.order.id
90
100
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.1
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patch Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus