patch_ruby 1.0.0.pre

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 (68) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/Gemfile.lock +72 -0
  4. data/README.md +54 -0
  5. data/Rakefile +10 -0
  6. data/lib/patch_ruby.rb +61 -0
  7. data/lib/patch_ruby/api/estimates_api.rb +213 -0
  8. data/lib/patch_ruby/api/orders_api.rb +339 -0
  9. data/lib/patch_ruby/api/preferences_api.rb +276 -0
  10. data/lib/patch_ruby/api/projects_api.rb +148 -0
  11. data/lib/patch_ruby/api_client.rb +388 -0
  12. data/lib/patch_ruby/api_error.rb +57 -0
  13. data/lib/patch_ruby/configuration.rb +254 -0
  14. data/lib/patch_ruby/models/allocation.rb +229 -0
  15. data/lib/patch_ruby/models/create_mass_estimate_request.rb +216 -0
  16. data/lib/patch_ruby/models/create_order_request.rb +216 -0
  17. data/lib/patch_ruby/models/create_preference_request.rb +216 -0
  18. data/lib/patch_ruby/models/error_response.rb +239 -0
  19. data/lib/patch_ruby/models/estimate.rb +238 -0
  20. data/lib/patch_ruby/models/estimate_list_response.rb +255 -0
  21. data/lib/patch_ruby/models/estimate_response.rb +239 -0
  22. data/lib/patch_ruby/models/meta_index_object.rb +220 -0
  23. data/lib/patch_ruby/models/order.rb +313 -0
  24. data/lib/patch_ruby/models/order_list_response.rb +255 -0
  25. data/lib/patch_ruby/models/order_response.rb +239 -0
  26. data/lib/patch_ruby/models/preference.rb +229 -0
  27. data/lib/patch_ruby/models/preference_list_response.rb +255 -0
  28. data/lib/patch_ruby/models/preference_response.rb +239 -0
  29. data/lib/patch_ruby/models/project.rb +283 -0
  30. data/lib/patch_ruby/models/project_list_response.rb +255 -0
  31. data/lib/patch_ruby/models/project_response.rb +239 -0
  32. data/lib/patch_ruby/version.rb +15 -0
  33. data/patch_ruby.gemspec +39 -0
  34. data/spec/api/estimates_api_spec.rb +71 -0
  35. data/spec/api/orders_api_spec.rb +95 -0
  36. data/spec/api/preferences_api_spec.rb +83 -0
  37. data/spec/api/projects_api_spec.rb +59 -0
  38. data/spec/api_client_spec.rb +226 -0
  39. data/spec/configuration_spec.rb +42 -0
  40. data/spec/fixtures/vcr_cassettes/estimate_orders.yml +276 -0
  41. data/spec/fixtures/vcr_cassettes/estimates.yml +211 -0
  42. data/spec/fixtures/vcr_cassettes/orders.yml +229 -0
  43. data/spec/fixtures/vcr_cassettes/preferences.yml +352 -0
  44. data/spec/fixtures/vcr_cassettes/projects.yml +143 -0
  45. data/spec/integration/estimates_spec.rb +31 -0
  46. data/spec/integration/orders_spec.rb +53 -0
  47. data/spec/integration/preferences_spec.rb +40 -0
  48. data/spec/integration/projects_spec.rb +31 -0
  49. data/spec/models/allocation_spec.rb +53 -0
  50. data/spec/models/create_mass_estimate_request_spec.rb +41 -0
  51. data/spec/models/create_order_request_spec.rb +41 -0
  52. data/spec/models/create_preference_request_spec.rb +41 -0
  53. data/spec/models/error_response_spec.rb +53 -0
  54. data/spec/models/estimate_list_response_spec.rb +59 -0
  55. data/spec/models/estimate_response_spec.rb +53 -0
  56. data/spec/models/estimate_spec.rb +59 -0
  57. data/spec/models/meta_index_object_spec.rb +47 -0
  58. data/spec/models/order_list_response_spec.rb +59 -0
  59. data/spec/models/order_response_spec.rb +53 -0
  60. data/spec/models/order_spec.rb +85 -0
  61. data/spec/models/preference_list_response_spec.rb +59 -0
  62. data/spec/models/preference_response_spec.rb +53 -0
  63. data/spec/models/preference_spec.rb +53 -0
  64. data/spec/models/project_list_response_spec.rb +59 -0
  65. data/spec/models/project_response_spec.rb +53 -0
  66. data/spec/models/project_spec.rb +89 -0
  67. data/spec/spec_helper.rb +122 -0
  68. metadata +203 -0
@@ -0,0 +1,143 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.staging-patch.com/v1/projects?page=1
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenAPI-Generator/1.0.0.pre/ruby
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ Authorization:
17
+ - "<AUTH>"
18
+ Expect:
19
+ - ''
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: ''
24
+ headers:
25
+ server:
26
+ - nginx/1.17.8
27
+ date:
28
+ - Thu, 02 Jul 2020 17:44:24 GMT
29
+ content-type:
30
+ - application/json; charset=utf-8
31
+ vary:
32
+ - Accept-Encoding
33
+ - Origin
34
+ x-frame-options:
35
+ - SAMEORIGIN
36
+ x-xss-protection:
37
+ - 1; mode=block
38
+ x-content-type-options:
39
+ - nosniff
40
+ x-download-options:
41
+ - noopen
42
+ x-permitted-cross-domain-policies:
43
+ - none
44
+ referrer-policy:
45
+ - strict-origin-when-cross-origin
46
+ etag:
47
+ - W/"4cb5a00231b4a4af0a924c8965c78a3c"
48
+ cache-control:
49
+ - max-age=0, private, must-revalidate
50
+ x-request-id:
51
+ - e1e6cbb673e72cc20c3378bb78772040
52
+ x-runtime:
53
+ - '0.022308'
54
+ strict-transport-security:
55
+ - max-age=15724800; includeSubDomains
56
+ access-control-allow-origin:
57
+ - "*"
58
+ access-control-allow-credentials:
59
+ - 'true'
60
+ access-control-allow-methods:
61
+ - GET, PUT, POST, DELETE, PATCH, OPTIONS
62
+ access-control-allow-headers:
63
+ - DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
64
+ body:
65
+ encoding: UTF-8
66
+ string: '{"data":[{"id":"pro_test_cee5bba9672799a693891aff340b3106","country":"US","description":"This
67
+ project is an example.","developer":"Patch Test Developer","latitude":45.0,"longitude":45.0,"name":"Patch''s
68
+ Test Offset Project","production":false,"verifier":"Test verifier"}],"error":null,"meta":{"next_page":null,"prev_page":null},"success":true}'
69
+ http_version: '2'
70
+ adapter_metadata:
71
+ effective_url: https://api.staging-patch.com/v1/projects?page=1
72
+ recorded_at: Thu, 02 Jul 2020 17:44:24 GMT
73
+ - request:
74
+ method: get
75
+ uri: https://api.staging-patch.com/v1/projects/pro_test_cee5bba9672799a693891aff340b3106
76
+ body:
77
+ encoding: US-ASCII
78
+ string: ''
79
+ headers:
80
+ User-Agent:
81
+ - OpenAPI-Generator/1.0.0.pre/ruby
82
+ Content-Type:
83
+ - application/json
84
+ Accept:
85
+ - application/json
86
+ Authorization:
87
+ - "<AUTH>"
88
+ Expect:
89
+ - ''
90
+ response:
91
+ status:
92
+ code: 200
93
+ message: ''
94
+ headers:
95
+ server:
96
+ - nginx/1.17.8
97
+ date:
98
+ - Thu, 02 Jul 2020 17:44:25 GMT
99
+ content-type:
100
+ - application/json; charset=utf-8
101
+ vary:
102
+ - Accept-Encoding
103
+ - Origin
104
+ x-frame-options:
105
+ - SAMEORIGIN
106
+ x-xss-protection:
107
+ - 1; mode=block
108
+ x-content-type-options:
109
+ - nosniff
110
+ x-download-options:
111
+ - noopen
112
+ x-permitted-cross-domain-policies:
113
+ - none
114
+ referrer-policy:
115
+ - strict-origin-when-cross-origin
116
+ etag:
117
+ - W/"1bee28f83050ddecdadeaebcf81c6d6f"
118
+ cache-control:
119
+ - max-age=0, private, must-revalidate
120
+ x-request-id:
121
+ - c4bc4dc7cf503c5673a9818e4830360d
122
+ x-runtime:
123
+ - '0.033308'
124
+ strict-transport-security:
125
+ - max-age=15724800; includeSubDomains
126
+ access-control-allow-origin:
127
+ - "*"
128
+ access-control-allow-credentials:
129
+ - 'true'
130
+ access-control-allow-methods:
131
+ - GET, PUT, POST, DELETE, PATCH, OPTIONS
132
+ access-control-allow-headers:
133
+ - DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
134
+ body:
135
+ encoding: UTF-8
136
+ string: '{"data":{"id":"pro_test_cee5bba9672799a693891aff340b3106","country":"US","description":"This
137
+ project is an example.","developer":"Patch Test Developer","latitude":45.0,"longitude":45.0,"name":"Patch''s
138
+ Test Offset Project","production":false,"verifier":"Test verifier"},"error":null,"meta":null,"success":true}'
139
+ http_version: '2'
140
+ adapter_metadata:
141
+ effective_url: https://api.staging-patch.com/v1/projects/pro_test_cee5bba9672799a693891aff340b3106
142
+ recorded_at: Thu, 02 Jul 2020 17:44:25 GMT
143
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Estimates Integration' do
4
+ it "supports create, retrieve and list" do
5
+ VCR.use_cassette('estimates') do
6
+ # Configure the Patch gem
7
+ Patch.configure do |config|
8
+ config.access_token = ENV['PATCH_RUBY_API_KEY']
9
+ config.host = ENV['PATCH_RUBY_HOST']
10
+ end
11
+
12
+ create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
13
+ estimate_id = create_estimate_response.data.id
14
+
15
+ retrieve_estimate_response = Patch::Estimate.retrieve_estimate(estimate_id)
16
+ expect(retrieve_estimate_response.data.id).to eq estimate_id
17
+
18
+ page_limit = 1
19
+ next_page = 1
20
+ estimates = []
21
+
22
+ while !next_page.nil? && next_page <= page_limit
23
+ retrieve_estimates_response = Patch::Estimate.retrieve_estimates(page: next_page)
24
+ next_page = retrieve_estimates_response.meta.next_page
25
+ estimates += retrieve_estimates_response.data
26
+ end
27
+
28
+ expect(estimates.length).not_to be_zero
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Orders Integration' do
4
+ it "supports create, place, cancel, retrieve and list" do
5
+ VCR.use_cassette('orders') do
6
+ # Configure the Patch gem
7
+ Patch.configure do |config|
8
+ config.access_token = ENV['PATCH_RUBY_API_KEY']
9
+ config.host = ENV['PATCH_RUBY_HOST']
10
+ end
11
+
12
+ create_order_response = Patch::Order.create_order(mass_g: 100)
13
+ order_id = create_order_response.data.id
14
+
15
+ retrieve_order_response = Patch::Order.retrieve_order(order_id)
16
+ expect(retrieve_order_response.data.id).to eq order_id
17
+
18
+ # place_order_response = Patch::Order.place_order(order_id)
19
+ # expect(place_order_response.data.state).to eq 'placed'
20
+
21
+ # place_order_response = Patch::Order.cancel_order(order_id)
22
+ # expect(place_order_response.data.state).to eq 'cancelled'
23
+
24
+ page_limit = 1
25
+ next_page = 1
26
+ orders = []
27
+
28
+ while !next_page.nil? && next_page <= page_limit
29
+ retrieve_orders_response = Patch::Order.retrieve_orders(page: next_page)
30
+ next_page = retrieve_orders_response.meta.next_page
31
+ orders += retrieve_orders_response.data
32
+ end
33
+
34
+ expect(orders.length).not_to be_zero
35
+ end
36
+ end
37
+
38
+ it "supports place and cancel for order created via an estimate" do
39
+ VCR.use_cassette('estimate_orders') do
40
+ create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
41
+ order_to_place_id = create_estimate_to_place_response.data.order.id
42
+
43
+ place_order_response = Patch::Order.place_order(order_to_place_id)
44
+ expect(place_order_response.data.state).to eq 'placed'
45
+
46
+ create_estimate_to_cancel_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
47
+ order_to_cancel_id = create_estimate_to_cancel_response.data.order.id
48
+
49
+ cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id)
50
+ expect(cancel_order_response.data.state).to eq 'cancelled'
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Preferences Integration' do
4
+ it "supports create, delete, retrieve and list" do
5
+ VCR.use_cassette('preferences') do
6
+ # Configure the Patch gem
7
+ Patch.configure do |config|
8
+ config.access_token = ENV['PATCH_RUBY_API_KEY']
9
+ config.host = ENV['PATCH_RUBY_HOST']
10
+ end
11
+
12
+ retrieve_projects_response = Patch::Project.retrieve_projects
13
+ expect(retrieve_projects_response.data.length).not_to be_zero
14
+ project_id = retrieve_projects_response.data.first.id
15
+
16
+ create_preference_response = Patch::Preference.create_preference(project_id: project_id)
17
+ preference_id = create_preference_response.data.id
18
+
19
+ retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
20
+ expect(retrieve_preference_response.data.id).to eq preference_id
21
+
22
+ # START receive_preferences
23
+ page_limit = 1
24
+ next_page = 1
25
+ preferences = []
26
+
27
+ while !next_page.nil? && next_page <= page_limit
28
+ retrieve_preferences_response = Patch::Preference.retrieve_preferences(page: next_page)
29
+ next_page = retrieve_preferences_response.meta.next_page
30
+ preferences += retrieve_preferences_response.data
31
+ end
32
+
33
+ expect(preferences.length).not_to be_zero
34
+ # END receive_preferences
35
+
36
+ delete_preference_response = Patch::Preference.delete_preference(preference_id)
37
+ expect(delete_preference_response.data.id).to eq preference_id
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Projects Integration' do
4
+ it "supports retrieve and list" do
5
+ VCR.use_cassette('projects') do
6
+ # Configure the Patch gem
7
+ Patch.configure do |config|
8
+ config.access_token = ENV['PATCH_RUBY_API_KEY']
9
+ config.host = ENV['PATCH_RUBY_HOST']
10
+ end
11
+
12
+ # START receive_projects
13
+ page_limit = 1
14
+ next_page = 1
15
+ projects = []
16
+
17
+ while !next_page.nil? && next_page <= page_limit
18
+ retrieve_projects_response = Patch::Project.retrieve_projects(page: next_page)
19
+ next_page = retrieve_projects_response.meta.next_page
20
+ projects += retrieve_projects_response.data
21
+ end
22
+
23
+ expect(projects.length).not_to be_zero
24
+ project_id = retrieve_projects_response.data.first.id
25
+ # END receive_projects
26
+
27
+ retrieve_project_response = Patch::Project.retrieve_project(project_id)
28
+ expect(retrieve_project_response.data.id).to eq project_id
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,53 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for Patch::Allocation
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe 'Allocation' do
21
+ before do
22
+ # run before each test
23
+ @instance = Patch::Allocation.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of Allocation' do
31
+ it 'should create an instance of Allocation' do
32
+ expect(@instance).to be_instance_of(Patch::Allocation)
33
+ end
34
+ end
35
+ describe 'test attribute "id"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "production"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "mass_g"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,41 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for Patch::CreateMassEstimateRequest
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe 'CreateMassEstimateRequest' do
21
+ before do
22
+ # run before each test
23
+ @instance = Patch::CreateMassEstimateRequest.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of CreateMassEstimateRequest' do
31
+ it 'should create an instance of CreateMassEstimateRequest' do
32
+ expect(@instance).to be_instance_of(Patch::CreateMassEstimateRequest)
33
+ end
34
+ end
35
+ describe 'test attribute "mass_g"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,41 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for Patch::CreateOrderRequest
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe 'CreateOrderRequest' do
21
+ before do
22
+ # run before each test
23
+ @instance = Patch::CreateOrderRequest.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of CreateOrderRequest' do
31
+ it 'should create an instance of CreateOrderRequest' do
32
+ expect(@instance).to be_instance_of(Patch::CreateOrderRequest)
33
+ end
34
+ end
35
+ describe 'test attribute "mass_g"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,41 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+ require 'date'
16
+
17
+ # Unit tests for Patch::CreatePreferenceRequest
18
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
19
+ # Please update as you see appropriate
20
+ describe 'CreatePreferenceRequest' do
21
+ before do
22
+ # run before each test
23
+ @instance = Patch::CreatePreferenceRequest.new
24
+ end
25
+
26
+ after do
27
+ # run after each test
28
+ end
29
+
30
+ describe 'test an instance of CreatePreferenceRequest' do
31
+ it 'should create an instance of CreatePreferenceRequest' do
32
+ expect(@instance).to be_instance_of(Patch::CreatePreferenceRequest)
33
+ end
34
+ end
35
+ describe 'test attribute "project_id"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ end