patch_ruby 1.2.4 → 1.2.5
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -2
- data/lib/patch_ruby/models/allocation.rb +10 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -0
- data/lib/patch_ruby/models/create_order_request.rb +7 -0
- data/lib/patch_ruby/models/create_preference_request.rb +7 -0
- data/lib/patch_ruby/models/error_response.rb +9 -0
- data/lib/patch_ruby/models/estimate.rb +14 -1
- data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
- data/lib/patch_ruby/models/estimate_response.rb +9 -0
- data/lib/patch_ruby/models/meta_index_object.rb +11 -0
- data/lib/patch_ruby/models/order.rb +20 -0
- data/lib/patch_ruby/models/order_list_response.rb +9 -0
- data/lib/patch_ruby/models/order_response.rb +9 -0
- data/lib/patch_ruby/models/photo.rb +21 -4
- data/lib/patch_ruby/models/preference.rb +10 -0
- data/lib/patch_ruby/models/preference_list_response.rb +9 -0
- data/lib/patch_ruby/models/preference_response.rb +9 -0
- data/lib/patch_ruby/models/project.rb +22 -0
- data/lib/patch_ruby/models/project_list_response.rb +9 -0
- data/lib/patch_ruby/models/project_response.rb +9 -0
- data/lib/patch_ruby/models/standard.rb +10 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/factories/allocations.rb +7 -0
- data/spec/factories/create_mass_estimate_requests.rb +6 -0
- data/spec/factories/create_order_requests.rb +8 -0
- data/spec/factories/create_preference_requests.rb +5 -0
- data/spec/factories/error_responses.rb +7 -0
- data/spec/factories/estimate_list_responses.rb +8 -0
- data/spec/factories/estimate_responses.rb +7 -0
- data/spec/factories/estimates.rb +8 -0
- data/spec/factories/meta_index_objects.rb +6 -0
- data/spec/factories/order_list_responses.rb +8 -0
- data/spec/factories/order_responses.rb +7 -0
- data/spec/factories/orders.rb +12 -0
- data/spec/factories/preference_list_responses.rb +8 -0
- data/spec/factories/preference_responses.rb +7 -0
- data/spec/factories/preferences.rb +7 -0
- data/spec/factories/project_list_responses.rb +8 -0
- data/spec/factories/project_responses.rb +7 -0
- data/spec/factories/projects.rb +15 -0
- data/spec/integration/estimates_spec.rb +0 -11
- data/spec/integration/orders_spec.rb +1 -1
- data/spec/models/allocation_spec.rb +8 -1
- data/spec/models/create_mass_estimate_request_spec.rb +7 -1
- data/spec/models/create_order_request_spec.rb +7 -1
- data/spec/models/create_preference_request_spec.rb +8 -1
- data/spec/models/error_response_spec.rb +7 -1
- data/spec/models/estimate_list_response_spec.rb +7 -1
- data/spec/models/estimate_response_spec.rb +7 -1
- data/spec/models/estimate_spec.rb +8 -1
- data/spec/models/meta_index_object_spec.rb +7 -1
- data/spec/models/order_list_response_spec.rb +7 -1
- data/spec/models/order_response_spec.rb +7 -1
- data/spec/models/order_spec.rb +18 -1
- data/spec/models/preference_list_response_spec.rb +7 -1
- data/spec/models/preference_response_spec.rb +7 -1
- data/spec/models/preference_spec.rb +7 -1
- data/spec/models/project_list_response_spec.rb +7 -1
- data/spec/models/project_response_spec.rb +7 -1
- data/spec/models/project_spec.rb +21 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/support/shared/generated_classes.rb +13 -0
- metadata +57 -19
@@ -42,6 +42,15 @@ module Patch
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("error")
|
50
|
+
|
51
|
+
nullable_properties
|
52
|
+
end
|
53
|
+
|
45
54
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
46
55
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
47
56
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -38,6 +38,15 @@ module Patch
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set with nullable attributes.
|
42
|
+
def self.openapi_nullable
|
43
|
+
nullable_properties = Set.new
|
44
|
+
|
45
|
+
nullable_properties.add("error")
|
46
|
+
|
47
|
+
nullable_properties
|
48
|
+
end
|
49
|
+
|
41
50
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
51
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
52
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -14,26 +14,37 @@ require 'date'
|
|
14
14
|
|
15
15
|
module Patch
|
16
16
|
class Project
|
17
|
+
# A unique uid for the record. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in.
|
17
18
|
attr_accessor :id
|
18
19
|
|
20
|
+
# A boolean indicating if this project is a production or test mode project.
|
19
21
|
attr_accessor :production
|
20
22
|
|
23
|
+
# The name of the project.
|
21
24
|
attr_accessor :name
|
22
25
|
|
26
|
+
# The description of the project.
|
23
27
|
attr_accessor :description
|
24
28
|
|
29
|
+
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Soil.
|
25
30
|
attr_accessor :type
|
26
31
|
|
32
|
+
# The country of origin of the project.
|
27
33
|
attr_accessor :country
|
28
34
|
|
35
|
+
# The name of the project developer.
|
29
36
|
attr_accessor :developer
|
30
37
|
|
38
|
+
# An array of URLs for photos of the project.
|
31
39
|
attr_accessor :photos
|
32
40
|
|
41
|
+
# The average price per tonne in USD cents for carbon offsets supplied by this project.
|
33
42
|
attr_accessor :average_price_per_tonne_cents_usd
|
34
43
|
|
44
|
+
# The remaining mass in grams available for purchase for this project.
|
35
45
|
attr_accessor :remaining_mass_g
|
36
46
|
|
47
|
+
# An object returning the Standard associated with this project.
|
37
48
|
attr_accessor :standard
|
38
49
|
|
39
50
|
class EnumAttributeValidator
|
@@ -92,6 +103,17 @@ module Patch
|
|
92
103
|
}
|
93
104
|
end
|
94
105
|
|
106
|
+
# Set with nullable attributes.
|
107
|
+
def self.openapi_nullable
|
108
|
+
nullable_properties = Set.new
|
109
|
+
|
110
|
+
nullable_properties.add("photos")
|
111
|
+
|
112
|
+
nullable_properties.add("standard")
|
113
|
+
|
114
|
+
nullable_properties
|
115
|
+
end
|
116
|
+
|
95
117
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
96
118
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
97
119
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -42,6 +42,15 @@ module Patch
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("error")
|
50
|
+
|
51
|
+
nullable_properties
|
52
|
+
end
|
53
|
+
|
45
54
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
46
55
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
47
56
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -38,6 +38,15 @@ module Patch
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
# Set with nullable attributes.
|
42
|
+
def self.openapi_nullable
|
43
|
+
nullable_properties = Set.new
|
44
|
+
|
45
|
+
nullable_properties.add("error")
|
46
|
+
|
47
|
+
nullable_properties
|
48
|
+
end
|
49
|
+
|
41
50
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
51
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
52
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -14,10 +14,13 @@ require 'date'
|
|
14
14
|
|
15
15
|
module Patch
|
16
16
|
class Standard
|
17
|
+
# The standard type.
|
17
18
|
attr_accessor :type
|
18
19
|
|
20
|
+
# The acronym for the standard.
|
19
21
|
attr_accessor :acronym
|
20
22
|
|
23
|
+
# The description of the standard.
|
21
24
|
attr_accessor :description
|
22
25
|
|
23
26
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -38,6 +41,13 @@ module Patch
|
|
38
41
|
}
|
39
42
|
end
|
40
43
|
|
44
|
+
# Set with nullable attributes.
|
45
|
+
def self.openapi_nullable
|
46
|
+
nullable_properties = Set.new
|
47
|
+
|
48
|
+
nullable_properties
|
49
|
+
end
|
50
|
+
|
41
51
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
52
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
53
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
data/lib/patch_ruby/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :order, class: Patch::Order do
|
3
|
+
sequence(:id) { |n| n }
|
4
|
+
mass_g { 1_000 }
|
5
|
+
production { false }
|
6
|
+
state { "draft" }
|
7
|
+
allocation_state { "pending" }
|
8
|
+
price_cents_usd { 500 }
|
9
|
+
patch_fee_cents_usd { 5 }
|
10
|
+
metadata { {} }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :project, class: Patch::Project do
|
3
|
+
sequence(:id) { |n| n }
|
4
|
+
production { false }
|
5
|
+
name { "New Project" }
|
6
|
+
description { "New Descirption" }
|
7
|
+
type { "biomass" }
|
8
|
+
country { "DK" }
|
9
|
+
developer { "Danish Developer" }
|
10
|
+
photos { [] }
|
11
|
+
average_price_per_tonne_cents_usd { 120 }
|
12
|
+
remaining_mass_g { 1_000 }
|
13
|
+
standard { 'european_biochar_certificate' }
|
14
|
+
end
|
15
|
+
end
|
@@ -24,15 +24,4 @@ RSpec.describe 'Estimates Integration' do
|
|
24
24
|
|
25
25
|
expect(estimates.length).not_to be_zero
|
26
26
|
end
|
27
|
-
|
28
|
-
it 'supports create with a project-id' do
|
29
|
-
retrieve_projects_response = Patch::Project.retrieve_projects(page: 1)
|
30
|
-
project_id = retrieve_projects_response.data.first.id
|
31
|
-
create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100, project_id: project_id)
|
32
|
-
estimate_id = create_estimate_response.data.id
|
33
|
-
|
34
|
-
expect(create_estimate_response.success).to eq true
|
35
|
-
expect(create_estimate_response.data.order.id).not_to be_nil
|
36
|
-
expect(create_estimate_response.data.order.mass_g).to eq(100)
|
37
|
-
end
|
38
27
|
end
|
@@ -65,7 +65,7 @@ RSpec.describe 'Orders Integration' do
|
|
65
65
|
order = create_order_response.data
|
66
66
|
|
67
67
|
expect(order.id).not_to be_nil
|
68
|
-
expect(order.mass_g).to eq(
|
68
|
+
expect(order.mass_g).to eq(5_00_000)
|
69
69
|
expect(order.price_cents_usd.to_i).to eq(500)
|
70
70
|
expect(order.patch_fee_cents_usd).not_to be_empty
|
71
71
|
expect(
|
@@ -20,18 +20,25 @@ require 'date'
|
|
20
20
|
describe 'Allocation' do
|
21
21
|
before do
|
22
22
|
# run before each test
|
23
|
-
@instance =
|
23
|
+
@instance = build(:allocation)
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
27
27
|
# run after each test
|
28
28
|
end
|
29
29
|
|
30
|
+
it_behaves_like "a generated class" do
|
31
|
+
let(:instance) { @instance }
|
32
|
+
let(:instance_hash) { { id: @instance.id, mass_g: @instance.mass_g, production: @instance.production } }
|
33
|
+
let(:nullable_properties) { Set.new }
|
34
|
+
end
|
35
|
+
|
30
36
|
describe 'test an instance of Allocation' do
|
31
37
|
it 'should create an instance of Allocation' do
|
32
38
|
expect(@instance).to be_instance_of(Patch::Allocation)
|
33
39
|
end
|
34
40
|
end
|
41
|
+
|
35
42
|
describe 'test attribute "id"' do
|
36
43
|
it 'should work' do
|
37
44
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
@@ -20,13 +20,19 @@ require 'date'
|
|
20
20
|
describe 'CreateMassEstimateRequest' do
|
21
21
|
before do
|
22
22
|
# run before each test
|
23
|
-
@instance =
|
23
|
+
@instance = build(:create_mass_estimate_request)
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
27
27
|
# run after each test
|
28
28
|
end
|
29
29
|
|
30
|
+
it_behaves_like "a generated class" do
|
31
|
+
let(:instance) { @instance }
|
32
|
+
let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g } }
|
33
|
+
let(:nullable_properties) { Set.new }
|
34
|
+
end
|
35
|
+
|
30
36
|
describe 'test an instance of CreateMassEstimateRequest' do
|
31
37
|
it 'should create an instance of CreateMassEstimateRequest' do
|
32
38
|
expect(@instance).to be_instance_of(Patch::CreateMassEstimateRequest)
|
@@ -20,13 +20,19 @@ require 'date'
|
|
20
20
|
describe 'CreateOrderRequest' do
|
21
21
|
before do
|
22
22
|
# run before each test
|
23
|
-
@instance =
|
23
|
+
@instance = build(:create_order_request)
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
27
27
|
# run after each test
|
28
28
|
end
|
29
29
|
|
30
|
+
it_behaves_like "a generated class" do
|
31
|
+
let(:instance) { @instance }
|
32
|
+
let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
|
33
|
+
let(:nullable_properties) { Set.new }
|
34
|
+
end
|
35
|
+
|
30
36
|
describe 'test an instance of CreateOrderRequest' do
|
31
37
|
it 'should create an instance of CreateOrderRequest' do
|
32
38
|
expect(@instance).to be_instance_of(Patch::CreateOrderRequest)
|
@@ -20,18 +20,25 @@ require 'date'
|
|
20
20
|
describe 'CreatePreferenceRequest' do
|
21
21
|
before do
|
22
22
|
# run before each test
|
23
|
-
@instance =
|
23
|
+
@instance = build(:create_preference_request)
|
24
24
|
end
|
25
25
|
|
26
26
|
after do
|
27
27
|
# run after each test
|
28
28
|
end
|
29
29
|
|
30
|
+
it_behaves_like "a generated class" do
|
31
|
+
let(:instance) { @instance }
|
32
|
+
let(:instance_hash) { { project_id: @instance.project_id } }
|
33
|
+
let(:nullable_properties) { Set.new }
|
34
|
+
end
|
35
|
+
|
30
36
|
describe 'test an instance of CreatePreferenceRequest' do
|
31
37
|
it 'should create an instance of CreatePreferenceRequest' do
|
32
38
|
expect(@instance).to be_instance_of(Patch::CreatePreferenceRequest)
|
33
39
|
end
|
34
40
|
end
|
41
|
+
|
35
42
|
describe 'test attribute "project_id"' do
|
36
43
|
it 'should work' do
|
37
44
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|