diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d32b2b1 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,148 @@ +# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) +# Automatically generated by OpenAPI Generator (https://openapi-generator.tech) +AllCops: + TargetRubyVersion: 2.4 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/FirstArgumentIndentation: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: false + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: false + EnforcedStyle: always + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +#Style/StringLiterals: +# Enabled: true +# EnforcedStyle: single_quotes + +# Detect hard tabs, no hard tabs. +Layout/IndentationStyle: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingEmptyLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: false + +# Use quotes for string literals when they are enough. +Style/RedundantPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..733fca9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.1.0] - 2020-08-19 + +### Added + +- `project_id` optional field to `order` creation +- `metadata` optional field to `order` creation +- `project_id` optional field to `estimate` creation +- changelog file + +## [1.0.0] - 2020-07-05 + +### Added + +- This is the first official release of Patch's Ruby Gem. + +## [1.0.0.pre] - 2020-07-02 + +### Added + +- Pre-release of v1 Gem +- Adds support for Orders, Estimates, Projects and Preferences + diff --git a/Gemfile.lock b/Gemfile.lock index 3ab5002..dce0dea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.0.0) + patch_ruby (1.1.0) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) diff --git a/README.md b/README.md index 5022141..ca40d2b 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,14 @@ In Patch, orders represent a purchase of carbon offsets or negative emissions by mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne) Patch::Order.create_order(mass_g: mass) +## You can also specify a project-id field (optional) to be used instead of the preferred one +project_id = 'pro_test_1234' # Pass in the project's ID +Patch::Order.create_order(mass_g: mass, project_id: project_id) + +## Orders also accept a metadata field (optional) +metadata = {user: "john doe"} +Patch::Order.create_order(mass_g: mass, metadata: metadata) + # Retrieve an order order_id = 'ord_test_1234' # Pass in the order's id Patch::Order.retrieve_order(order_id) @@ -81,6 +89,10 @@ Estimates allow API users to get a quote for the cost of compensating a certain mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne) Patch::Estimate.create_mass_estimate(mass_g: mass) +## You can also specify a project-id field (optional) to be used instead of the preferred one +project_id = 'pro_test_1234' # Pass in the project's ID +Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id) + # Retrieve an estimate estimate_id = 'est_test_1234' Patch::Estimate.retrieve_estimate(estimate_id) @@ -129,3 +141,30 @@ Patch::Preference.delete_preference(preference_id) page = 1 # Pass in which page of preferences you'd like Patch::Preference.retrieve_preferences(page: page) ``` + +## Development + +To build the gem locally, run: +``` +$ gem build patch_ruby.gemspec +``` + +This will create a .gem file. To install the local gem: +``` +$ gem install patch_ruby-1.x.x.gem +``` + +Install dependencies: +``` +$ bundle install +``` + +Set up required environment variables: +``` +$ export PATCH_RUBY_API_KEY= +``` + +Run tests: +``` +$ bundle exec rspec +``` diff --git a/lib/patch_ruby/api/estimates_api.rb b/lib/patch_ruby/api/estimates_api.rb index 79161ff..0988333 100644 --- a/lib/patch_ruby/api/estimates_api.rb +++ b/lib/patch_ruby/api/estimates_api.rb @@ -25,10 +25,9 @@ class EstimatesApi def initialize(api_client = ApiClient.default) @api_client = api_client end - # Create an estimate based on mass of CO2 - # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. - # @param create_mass_estimate_request [CreateMassEstimateRequest] + # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. + # @param create_mass_estimate_request [CreateMassEstimateRequest] # @param [Hash] opts the optional parameters # @return [EstimateResponse] def create_mass_estimate(create_mass_estimate_request, opts = {}) @@ -37,8 +36,8 @@ def create_mass_estimate(create_mass_estimate_request, opts = {}) end # Create an estimate based on mass of CO2 - # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. - # @param create_mass_estimate_request [CreateMassEstimateRequest] + # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. + # @param create_mass_estimate_request [CreateMassEstimateRequest] # @param [Hash] opts the optional parameters # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) @@ -49,7 +48,6 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) if @api_client.config.client_side_validation && create_mass_estimate_request.nil? fail ArgumentError, "Missing the required parameter 'create_mass_estimate_request' when calling EstimatesApi.create_mass_estimate" end - # resource path local_var_path = '/v1/estimates/mass' @@ -67,10 +65,10 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_mass_estimate_request) + post_body = opts[:body] || @api_client.object_to_http_body(create_mass_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:return_type] || 'EstimateResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -92,8 +90,8 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) end # Retrieves an estimate - # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. - # @param id [String] + # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. + # @param id [String] # @param [Hash] opts the optional parameters # @return [EstimateResponse] def retrieve_estimate(id, opts = {}) @@ -102,8 +100,8 @@ def retrieve_estimate(id, opts = {}) end # Retrieves an estimate - # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. - # @param id [String] + # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def retrieve_estimate_with_http_info(id, opts = {}) @@ -114,7 +112,6 @@ def retrieve_estimate_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling EstimatesApi.retrieve_estimate" end - # resource path local_var_path = '/v1/estimates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -130,10 +127,10 @@ def retrieve_estimate_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:return_type] || 'EstimateResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -155,9 +152,9 @@ def retrieve_estimate_with_http_info(id, opts = {}) end # Retrieves a list of estimates - # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. + # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [EstimateListResponse] def retrieve_estimates(opts = {}) data, _status_code, _headers = retrieve_estimates_with_http_info(opts) @@ -165,9 +162,9 @@ def retrieve_estimates(opts = {}) end # Retrieves a list of estimates - # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. + # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [Array<(EstimateListResponse, Integer, Hash)>] EstimateListResponse data, response status code and response headers def retrieve_estimates_with_http_info(opts = {}) if @api_client.config.debugging @@ -189,10 +186,10 @@ def retrieve_estimates_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'EstimateListResponse' + return_type = opts[:return_type] || 'EstimateListResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index cc3d471..faf6d4d 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -27,10 +27,9 @@ class OrdersApi def initialize(api_client = ApiClient.default) @api_client = api_client end - # Cancel an order - # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. - # @param id [String] + # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. + # @param id [String] # @param [Hash] opts the optional parameters # @return [OrderResponse] def cancel_order(id, opts = {}) @@ -39,8 +38,8 @@ def cancel_order(id, opts = {}) end # Cancel an order - # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. - # @param id [String] + # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def cancel_order_with_http_info(id, opts = {}) @@ -51,7 +50,6 @@ def cancel_order_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.cancel_order" end - # resource path local_var_path = '/v1/orders/{id}/cancel'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -67,10 +65,10 @@ def cancel_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:return_type] || 'OrderResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -92,8 +90,8 @@ def cancel_order_with_http_info(id, opts = {}) end # Creates an order - # Creates an order in the `placed` state. To create a `draft` order, create an estimate first. - # @param create_order_request [CreateOrderRequest] + # Creates an order in the `placed` state. To create a `draft` order, create an estimate first. + # @param create_order_request [CreateOrderRequest] # @param [Hash] opts the optional parameters # @return [OrderResponse] def create_order(create_order_request, opts = {}) @@ -102,8 +100,8 @@ def create_order(create_order_request, opts = {}) end # Creates an order - # Creates an order in the `placed` state. To create a `draft` order, create an estimate first. - # @param create_order_request [CreateOrderRequest] + # Creates an order in the `placed` state. To create a `draft` order, create an estimate first. + # @param create_order_request [CreateOrderRequest] # @param [Hash] opts the optional parameters # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def create_order_with_http_info(create_order_request, opts = {}) @@ -114,7 +112,6 @@ def create_order_with_http_info(create_order_request, opts = {}) if @api_client.config.client_side_validation && create_order_request.nil? fail ArgumentError, "Missing the required parameter 'create_order_request' when calling OrdersApi.create_order" end - # resource path local_var_path = '/v1/orders' @@ -132,10 +129,10 @@ def create_order_with_http_info(create_order_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_order_request) + post_body = opts[:body] || @api_client.object_to_http_body(create_order_request) # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:return_type] || 'OrderResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -157,8 +154,8 @@ def create_order_with_http_info(create_order_request, opts = {}) end # Place an order - # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed - # @param id [String] + # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed + # @param id [String] # @param [Hash] opts the optional parameters # @return [OrderResponse] def place_order(id, opts = {}) @@ -167,8 +164,8 @@ def place_order(id, opts = {}) end # Place an order - # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed - # @param id [String] + # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def place_order_with_http_info(id, opts = {}) @@ -179,7 +176,6 @@ def place_order_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.place_order" end - # resource path local_var_path = '/v1/orders/{id}/place'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -195,10 +191,10 @@ def place_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:return_type] || 'OrderResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -220,8 +216,8 @@ def place_order_with_http_info(id, opts = {}) end # Retrieves an order - # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. - # @param id [String] + # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. + # @param id [String] # @param [Hash] opts the optional parameters # @return [OrderResponse] def retrieve_order(id, opts = {}) @@ -230,8 +226,8 @@ def retrieve_order(id, opts = {}) end # Retrieves an order - # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. - # @param id [String] + # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def retrieve_order_with_http_info(id, opts = {}) @@ -242,7 +238,6 @@ def retrieve_order_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling OrdersApi.retrieve_order" end - # resource path local_var_path = '/v1/orders/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -258,10 +253,10 @@ def retrieve_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:return_type] || 'OrderResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -283,9 +278,9 @@ def retrieve_order_with_http_info(id, opts = {}) end # Retrieves a list of orders - # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. + # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [OrderListResponse] def retrieve_orders(opts = {}) data, _status_code, _headers = retrieve_orders_with_http_info(opts) @@ -293,9 +288,9 @@ def retrieve_orders(opts = {}) end # Retrieves a list of orders - # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. + # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers def retrieve_orders_with_http_info(opts = {}) if @api_client.config.debugging @@ -317,10 +312,10 @@ def retrieve_orders_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'OrderListResponse' + return_type = opts[:return_type] || 'OrderListResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] diff --git a/lib/patch_ruby/api/preferences_api.rb b/lib/patch_ruby/api/preferences_api.rb index 3e5353a..4d3f868 100644 --- a/lib/patch_ruby/api/preferences_api.rb +++ b/lib/patch_ruby/api/preferences_api.rb @@ -26,10 +26,9 @@ class PreferencesApi def initialize(api_client = ApiClient.default) @api_client = api_client end - # creates a project preference - # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. - # @param create_preference_request [CreatePreferenceRequest] + # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. + # @param create_preference_request [CreatePreferenceRequest] # @param [Hash] opts the optional parameters # @return [PreferenceResponse] def create_preference(create_preference_request, opts = {}) @@ -38,8 +37,8 @@ def create_preference(create_preference_request, opts = {}) end # creates a project preference - # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. - # @param create_preference_request [CreatePreferenceRequest] + # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. + # @param create_preference_request [CreatePreferenceRequest] # @param [Hash] opts the optional parameters # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers def create_preference_with_http_info(create_preference_request, opts = {}) @@ -50,7 +49,6 @@ def create_preference_with_http_info(create_preference_request, opts = {}) if @api_client.config.client_side_validation && create_preference_request.nil? fail ArgumentError, "Missing the required parameter 'create_preference_request' when calling PreferencesApi.create_preference" end - # resource path local_var_path = '/v1/preferences' @@ -68,10 +66,10 @@ def create_preference_with_http_info(create_preference_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_preference_request) + post_body = opts[:body] || @api_client.object_to_http_body(create_preference_request) # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:return_type] || 'PreferenceResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -93,8 +91,8 @@ def create_preference_with_http_info(create_preference_request, opts = {}) end # Deletes an organization's preference for a project - # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one. - # @param id [String] + # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one. + # @param id [String] # @param [Hash] opts the optional parameters # @return [PreferenceResponse] def delete_preference(id, opts = {}) @@ -103,8 +101,8 @@ def delete_preference(id, opts = {}) end # Deletes an organization's preference for a project - # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one. - # @param id [String] + # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers def delete_preference_with_http_info(id, opts = {}) @@ -115,7 +113,6 @@ def delete_preference_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.delete_preference" end - # resource path local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -131,10 +128,10 @@ def delete_preference_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:return_type] || 'PreferenceResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -156,8 +153,8 @@ def delete_preference_with_http_info(id, opts = {}) end # Retrieve the preference - # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization. - # @param id [String] + # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization. + # @param id [String] # @param [Hash] opts the optional parameters # @return [PreferenceResponse] def retrieve_preference(id, opts = {}) @@ -166,8 +163,8 @@ def retrieve_preference(id, opts = {}) end # Retrieve the preference - # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization. - # @param id [String] + # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers def retrieve_preference_with_http_info(id, opts = {}) @@ -178,7 +175,6 @@ def retrieve_preference_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.retrieve_preference" end - # resource path local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -194,10 +190,10 @@ def retrieve_preference_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:return_type] || 'PreferenceResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -219,9 +215,9 @@ def retrieve_preference_with_http_info(id, opts = {}) end # Retrieves a list of preferences - # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization. + # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [PreferenceListResponse] def retrieve_preferences(opts = {}) data, _status_code, _headers = retrieve_preferences_with_http_info(opts) @@ -229,9 +225,9 @@ def retrieve_preferences(opts = {}) end # Retrieves a list of preferences - # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization. + # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [Array<(PreferenceListResponse, Integer, Hash)>] PreferenceListResponse data, response status code and response headers def retrieve_preferences_with_http_info(opts = {}) if @api_client.config.debugging @@ -253,10 +249,10 @@ def retrieve_preferences_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'PreferenceListResponse' + return_type = opts[:return_type] || 'PreferenceListResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] diff --git a/lib/patch_ruby/api/projects_api.rb b/lib/patch_ruby/api/projects_api.rb index 555da1f..bc78ce0 100644 --- a/lib/patch_ruby/api/projects_api.rb +++ b/lib/patch_ruby/api/projects_api.rb @@ -24,10 +24,9 @@ class ProjectsApi def initialize(api_client = ApiClient.default) @api_client = api_client end - # Retrieves a project - # Retrieves a project available on Patch's platform. - # @param id [String] + # Retrieves a project available on Patch's platform. + # @param id [String] # @param [Hash] opts the optional parameters # @return [ProjectResponse] def retrieve_project(id, opts = {}) @@ -36,8 +35,8 @@ def retrieve_project(id, opts = {}) end # Retrieves a project - # Retrieves a project available on Patch's platform. - # @param id [String] + # Retrieves a project available on Patch's platform. + # @param id [String] # @param [Hash] opts the optional parameters # @return [Array<(ProjectResponse, Integer, Hash)>] ProjectResponse data, response status code and response headers def retrieve_project_with_http_info(id, opts = {}) @@ -48,7 +47,6 @@ def retrieve_project_with_http_info(id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ProjectsApi.retrieve_project" end - # resource path local_var_path = '/v1/projects/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -64,10 +62,10 @@ def retrieve_project_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'ProjectResponse' + return_type = opts[:return_type] || 'ProjectResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] @@ -89,9 +87,9 @@ def retrieve_project_with_http_info(id, opts = {}) end # Retrieves a list of projects - # Retrieves a list of projects available for purchase on Patch's platform. + # Retrieves a list of projects available for purchase on Patch's platform. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [ProjectListResponse] def retrieve_projects(opts = {}) data, _status_code, _headers = retrieve_projects_with_http_info(opts) @@ -99,9 +97,9 @@ def retrieve_projects(opts = {}) end # Retrieves a list of projects - # Retrieves a list of projects available for purchase on Patch's platform. + # Retrieves a list of projects available for purchase on Patch's platform. # @param [Hash] opts the optional parameters - # @option opts [Integer] :page + # @option opts [Integer] :page # @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers def retrieve_projects_with_http_info(opts = {}) if @api_client.config.debugging @@ -123,10 +121,10 @@ def retrieve_projects_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:body] # return_type - return_type = opts[:return_type] || 'ProjectListResponse' + return_type = opts[:return_type] || 'ProjectListResponse' # auth_names auth_names = opts[:auth_names] || ['bearer_auth'] diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 9c40ff8..517be7d 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -136,7 +136,7 @@ def build_request(http_method, path, opts = {}) def build_request_body(header_params, form_params, body) # http form if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || - header_params['Content-Type'] == 'multipart/form-data' + header_params['Content-Type'] == 'multipart/form-data' data = {} form_params.each do |key, value| case value @@ -207,7 +207,6 @@ def deserialize(response, return_type) # @return [Mixed] Data in a particular type def convert_to_type(data, return_type) return nil if data.nil? - case return_type when 'String' data.to_s @@ -304,7 +303,6 @@ def update_params_for_auth!(header_params, query_params, auth_names) Array(auth_names).each do |auth_name| auth_setting = @config.auth_settings[auth_name] next unless auth_setting - case auth_setting[:in] when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] @@ -326,7 +324,6 @@ def user_agent=(user_agent) # @return [String] the Accept header (e.g. application/json) def select_header_accept(accepts) return nil if accepts.nil? || accepts.empty? - # use JSON when present, otherwise use all of the provided json_accept = accepts.find { |s| json_mime?(s) } json_accept || accepts.join(',') @@ -338,7 +335,6 @@ def select_header_accept(accepts) def select_header_content_type(content_types) # use application/json by default return 'application/json' if content_types.nil? || content_types.empty? - # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } json_content_type || content_types.first @@ -349,7 +345,6 @@ def select_header_content_type(content_types) # @return [String] JSON string representation of the object def object_to_http_body(model) return model if model.nil? || model.is_a?(String) - local_body = nil if model.is_a?(Array) local_body = model.map { |m| object_to_hash(m) } diff --git a/lib/patch_ruby/configuration.rb b/lib/patch_ruby/configuration.rb index 77020f3..e0d1238 100644 --- a/lib/patch_ruby/configuration.rb +++ b/lib/patch_ruby/configuration.rb @@ -211,10 +211,10 @@ def server_settings description: "No description provided", variables: { defaultHost: { - description: "No description provided", - default_value: "api.usepatch.com", + description: "No description provided", + default_value: "api.usepatch.com", + } } - } } ] end diff --git a/lib/patch_ruby/models/allocation.rb b/lib/patch_ruby/models/allocation.rb index 7227381..78da294 100644 --- a/lib/patch_ruby/models/allocation.rb +++ b/lib/patch_ruby/models/allocation.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Allocation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -82,12 +81,27 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @production.nil? + invalid_properties.push('invalid value for "production", production cannot be nil.') + end + + if @mass_g.nil? + invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @id.nil? + return false if @production.nil? + return false if @mass_g.nil? true end @@ -95,11 +109,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - id == o.id && - production == o.production && - mass_g == o.mass_g + id == o.id && + production == o.production && + mass_g == o.mass_g end # @see the `==` method @@ -126,7 +139,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -205,7 +217,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_mass_estimate_request.rb b/lib/patch_ruby/models/create_mass_estimate_request.rb index d867299..b4f0241 100644 --- a/lib/patch_ruby/models/create_mass_estimate_request.rb +++ b/lib/patch_ruby/models/create_mass_estimate_request.rb @@ -16,17 +16,21 @@ module Patch class CreateMassEstimateRequest attr_accessor :mass_g + attr_accessor :project_id + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'mass_g' => :'mass_g' + :'mass_g' => :'mass_g', + :'project_id' => :'project_id' } end # Attribute type mapping. def self.openapi_types { - :'mass_g' => :'Integer' + :'mass_g' => :'Integer', + :'project_id' => :'String' } end @@ -53,13 +57,16 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateMassEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } if attributes.key?(:'mass_g') self.mass_g = attributes[:'mass_g'] end + + if attributes.key?(:'project_id') + self.project_id = attributes[:'project_id'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -77,7 +84,6 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @mass_g.nil? - true end @@ -85,9 +91,9 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - mass_g == o.mass_g + mass_g == o.mass_g && + project_id == o.project_id end # @see the `==` method @@ -99,7 +105,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [mass_g].hash + [mass_g, project_id].hash end # Builds the object from hash @@ -114,7 +120,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -193,7 +198,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_order_request.rb b/lib/patch_ruby/models/create_order_request.rb index 64518cd..716a78f 100644 --- a/lib/patch_ruby/models/create_order_request.rb +++ b/lib/patch_ruby/models/create_order_request.rb @@ -16,17 +16,25 @@ module Patch class CreateOrderRequest attr_accessor :mass_g + attr_accessor :project_id + + attr_accessor :metadata + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'mass_g' => :'mass_g' + :'mass_g' => :'mass_g', + :'project_id' => :'project_id', + :'metadata' => :'metadata' } end # Attribute type mapping. def self.openapi_types { - :'mass_g' => :'Integer' + :'mass_g' => :'Integer', + :'project_id' => :'String', + :'metadata' => :'Object' } end @@ -53,13 +61,20 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateOrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } if attributes.key?(:'mass_g') self.mass_g = attributes[:'mass_g'] end + + if attributes.key?(:'project_id') + self.project_id = attributes[:'project_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -77,7 +92,6 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @mass_g.nil? - true end @@ -85,9 +99,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - mass_g == o.mass_g + mass_g == o.mass_g && + project_id == o.project_id && + metadata == o.metadata end # @see the `==` method @@ -99,7 +114,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [mass_g].hash + [mass_g, project_id, metadata].hash end # Builds the object from hash @@ -114,7 +129,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -193,7 +207,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_preference_request.rb b/lib/patch_ruby/models/create_preference_request.rb index 07095e6..01c6920 100644 --- a/lib/patch_ruby/models/create_preference_request.rb +++ b/lib/patch_ruby/models/create_preference_request.rb @@ -53,7 +53,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreatePreferenceRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -77,7 +76,6 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @project_id.nil? - true end @@ -85,9 +83,8 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - project_id == o.project_id + project_id == o.project_id end # @see the `==` method @@ -114,7 +111,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -193,7 +189,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/error_response.rb b/lib/patch_ruby/models/error_response.rb index 717cb64..e9f70c8 100644 --- a/lib/patch_ruby/models/error_response.rb +++ b/lib/patch_ruby/models/error_response.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::ErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -98,7 +97,6 @@ def list_invalid_properties def valid? return false if @success.nil? return false if @error.nil? - true end @@ -106,11 +104,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -137,7 +134,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -216,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate.rb b/lib/patch_ruby/models/estimate.rb index f194e50..eaf55bc 100644 --- a/lib/patch_ruby/models/estimate.rb +++ b/lib/patch_ruby/models/estimate.rb @@ -65,7 +65,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Estimate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -90,12 +89,27 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @production.nil? + invalid_properties.push('invalid value for "production", production cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @id.nil? + return false if @production.nil? + return false if @type.nil? true end @@ -103,12 +117,11 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - id == o.id && - production == o.production && - type == o.type && - order == o.order + id == o.id && + production == o.production && + type == o.type && + order == o.order end # @see the `==` method @@ -135,7 +148,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -214,7 +226,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate_list_response.rb b/lib/patch_ruby/models/estimate_list_response.rb index ae2f150..6866d42 100644 --- a/lib/patch_ruby/models/estimate_list_response.rb +++ b/lib/patch_ruby/models/estimate_list_response.rb @@ -65,7 +65,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::EstimateListResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -113,7 +112,6 @@ def valid? return false if @success.nil? return false if @data.nil? return false if @meta.nil? - true end @@ -121,12 +119,11 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data && - meta == o.meta + success == o.success && + error == o.error && + data == o.data && + meta == o.meta end # @see the `==` method @@ -153,7 +150,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -232,7 +228,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate_response.rb b/lib/patch_ruby/models/estimate_response.rb index 9d34be2..aaed5d1 100644 --- a/lib/patch_ruby/models/estimate_response.rb +++ b/lib/patch_ruby/models/estimate_response.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::EstimateResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -98,7 +97,6 @@ def list_invalid_properties def valid? return false if @success.nil? return false if @data.nil? - true end @@ -106,11 +104,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -137,7 +134,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -216,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/meta_index_object.rb b/lib/patch_ruby/models/meta_index_object.rb index 2f0dbe6..fe2cc06 100644 --- a/lib/patch_ruby/models/meta_index_object.rb +++ b/lib/patch_ruby/models/meta_index_object.rb @@ -57,7 +57,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::MetaIndexObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -87,10 +86,9 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - prev_page == o.prev_page && - next_page == o.next_page + prev_page == o.prev_page && + next_page == o.next_page end # @see the `==` method @@ -117,7 +115,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -196,7 +193,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order.rb b/lib/patch_ruby/models/order.rb index 3db4355..427f56b 100644 --- a/lib/patch_ruby/models/order.rb +++ b/lib/patch_ruby/models/order.rb @@ -28,6 +28,8 @@ class Order attr_accessor :allocations + attr_accessor :metadata + class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values @@ -59,7 +61,8 @@ def self.attribute_map :'state' => :'state', :'allocation_state' => :'allocation_state', :'price_cents_usd' => :'price_cents_usd', - :'allocations' => :'allocations' + :'allocations' => :'allocations', + :'metadata' => :'metadata' } end @@ -72,7 +75,8 @@ def self.openapi_types :'state' => :'String', :'allocation_state' => :'String', :'price_cents_usd' => :'String', - :'allocations' => :'Array' + :'allocations' => :'Array', + :'metadata' => :'Object' } end @@ -99,7 +103,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Order`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -132,24 +135,61 @@ def initialize(attributes = {}) self.allocations = value end end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @mass_g.nil? + invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.') + end + + if @production.nil? + invalid_properties.push('invalid value for "production", production cannot be nil.') + end + + if @state.nil? + invalid_properties.push('invalid value for "state", state cannot be nil.') + end + + if @allocation_state.nil? + invalid_properties.push('invalid value for "allocation_state", allocation_state cannot be nil.') + end + + if @allocations.nil? + invalid_properties.push('invalid value for "allocations", allocations cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @id.nil? + return false if @mass_g.nil? + return false if @production.nil? + return false if @state.nil? state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "complete", "cancelled"]) return false unless state_validator.valid?(@state) - + return false if @allocation_state.nil? allocation_state_validator = EnumAttributeValidator.new('String', ["pending", "partially_allocated", "allocated"]) return false unless allocation_state_validator.valid?(@allocation_state) - + return false if @allocations.nil? + return false if @metadata.nil? true end @@ -160,7 +200,6 @@ def state=(state) unless validator.valid?(state) fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}." end - @state = state end @@ -171,7 +210,6 @@ def allocation_state=(allocation_state) unless validator.valid?(allocation_state) fail ArgumentError, "invalid value for \"allocation_state\", must be one of #{validator.allowable_values}." end - @allocation_state = allocation_state end @@ -179,15 +217,15 @@ def allocation_state=(allocation_state) # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - id == o.id && - mass_g == o.mass_g && - production == o.production && - state == o.state && - allocation_state == o.allocation_state && - price_cents_usd == o.price_cents_usd && - allocations == o.allocations + id == o.id && + mass_g == o.mass_g && + production == o.production && + state == o.state && + allocation_state == o.allocation_state && + price_cents_usd == o.price_cents_usd && + allocations == o.allocations && + metadata == o.metadata end # @see the `==` method @@ -199,7 +237,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, mass_g, production, state, allocation_state, price_cents_usd, allocations].hash + [id, mass_g, production, state, allocation_state, price_cents_usd, allocations, metadata].hash end # Builds the object from hash @@ -214,7 +252,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -293,7 +330,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order_list_response.rb b/lib/patch_ruby/models/order_list_response.rb index a531b58..9d889b0 100644 --- a/lib/patch_ruby/models/order_list_response.rb +++ b/lib/patch_ruby/models/order_list_response.rb @@ -65,7 +65,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderListResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -113,7 +112,6 @@ def valid? return false if @success.nil? return false if @data.nil? return false if @meta.nil? - true end @@ -121,12 +119,11 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data && - meta == o.meta + success == o.success && + error == o.error && + data == o.data && + meta == o.meta end # @see the `==` method @@ -153,7 +150,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -232,7 +228,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order_response.rb b/lib/patch_ruby/models/order_response.rb index 24d3eb1..4af787c 100644 --- a/lib/patch_ruby/models/order_response.rb +++ b/lib/patch_ruby/models/order_response.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -98,7 +97,6 @@ def list_invalid_properties def valid? return false if @success.nil? return false if @data.nil? - true end @@ -106,11 +104,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -137,7 +134,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -216,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference.rb b/lib/patch_ruby/models/preference.rb index 1e8d108..10bea26 100644 --- a/lib/patch_ruby/models/preference.rb +++ b/lib/patch_ruby/models/preference.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Preference`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -82,12 +81,27 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @allocation_percentage.nil? + invalid_properties.push('invalid value for "allocation_percentage", allocation_percentage cannot be nil.') + end + + if @project.nil? + invalid_properties.push('invalid value for "project", project cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @id.nil? + return false if @allocation_percentage.nil? + return false if @project.nil? true end @@ -95,11 +109,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - id == o.id && - allocation_percentage == o.allocation_percentage && - project == o.project + id == o.id && + allocation_percentage == o.allocation_percentage && + project == o.project end # @see the `==` method @@ -126,7 +139,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -205,7 +217,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference_list_response.rb b/lib/patch_ruby/models/preference_list_response.rb index 53d6cc5..fc8c29a 100644 --- a/lib/patch_ruby/models/preference_list_response.rb +++ b/lib/patch_ruby/models/preference_list_response.rb @@ -65,7 +65,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PreferenceListResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -113,7 +112,6 @@ def valid? return false if @success.nil? return false if @data.nil? return false if @meta.nil? - true end @@ -121,12 +119,11 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data && - meta == o.meta + success == o.success && + error == o.error && + data == o.data && + meta == o.meta end # @see the `==` method @@ -153,7 +150,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -232,7 +228,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference_response.rb b/lib/patch_ruby/models/preference_response.rb index ebc40b9..eb9c7ff 100644 --- a/lib/patch_ruby/models/preference_response.rb +++ b/lib/patch_ruby/models/preference_response.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PreferenceResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -98,7 +97,6 @@ def list_invalid_properties def valid? return false if @success.nil? return false if @data.nil? - true end @@ -106,11 +104,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -137,7 +134,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -216,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project.rb b/lib/patch_ruby/models/project.rb index 5cf4357..f547350 100644 --- a/lib/patch_ruby/models/project.rb +++ b/lib/patch_ruby/models/project.rb @@ -22,15 +22,33 @@ class Project attr_accessor :description - attr_accessor :country + attr_accessor :type - attr_accessor :longitude + attr_accessor :country - attr_accessor :latitude + attr_accessor :developer - attr_accessor :verifier + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - attr_accessor :developer + def valid?(value) + !value || allowable_values.include?(value) + end + end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map @@ -39,10 +57,8 @@ def self.attribute_map :'production' => :'production', :'name' => :'name', :'description' => :'description', + :'type' => :'type', :'country' => :'country', - :'longitude' => :'longitude', - :'latitude' => :'latitude', - :'verifier' => :'verifier', :'developer' => :'developer' } end @@ -54,10 +70,8 @@ def self.openapi_types :'production' => :'Boolean', :'name' => :'String', :'description' => :'String', + :'type' => :'String', :'country' => :'String', - :'longitude' => :'Float', - :'latitude' => :'Float', - :'verifier' => :'String', :'developer' => :'String' } end @@ -85,7 +99,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Project`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -105,20 +118,12 @@ def initialize(attributes = {}) self.description = attributes[:'description'] end - if attributes.key?(:'country') - self.country = attributes[:'country'] - end - - if attributes.key?(:'longitude') - self.longitude = attributes[:'longitude'] + if attributes.key?(:'type') + self.type = attributes[:'type'] end - if attributes.key?(:'latitude') - self.latitude = attributes[:'latitude'] - end - - if attributes.key?(:'verifier') - self.verifier = attributes[:'verifier'] + if attributes.key?(:'country') + self.country = attributes[:'country'] end if attributes.key?(:'developer') @@ -130,30 +135,69 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @production.nil? + invalid_properties.push('invalid value for "production", production cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @country.nil? + invalid_properties.push('invalid value for "country", country cannot be nil.') + end + + if @developer.nil? + invalid_properties.push('invalid value for "developer", developer cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @id.nil? + return false if @production.nil? + return false if @name.nil? + return false if @description.nil? + type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"]) + return false unless type_validator.valid?(@type) + return false if @country.nil? + return false if @developer.nil? true end + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - id == o.id && - production == o.production && - name == o.name && - description == o.description && - country == o.country && - longitude == o.longitude && - latitude == o.latitude && - verifier == o.verifier && - developer == o.developer + id == o.id && + production == o.production && + name == o.name && + description == o.description && + type == o.type && + country == o.country && + developer == o.developer end # @see the `==` method @@ -165,7 +209,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, production, name, description, country, longitude, latitude, verifier, developer].hash + [id, production, name, description, type, country, developer].hash end # Builds the object from hash @@ -180,7 +224,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -259,7 +302,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project_list_response.rb b/lib/patch_ruby/models/project_list_response.rb index 0d90fae..ca207a8 100644 --- a/lib/patch_ruby/models/project_list_response.rb +++ b/lib/patch_ruby/models/project_list_response.rb @@ -65,7 +65,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::ProjectListResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -113,7 +112,6 @@ def valid? return false if @success.nil? return false if @data.nil? return false if @meta.nil? - true end @@ -121,12 +119,11 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data && - meta == o.meta + success == o.success && + error == o.error && + data == o.data && + meta == o.meta end # @see the `==` method @@ -153,7 +150,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -232,7 +228,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project_response.rb b/lib/patch_ruby/models/project_response.rb index 19cb92b..3dfa634 100644 --- a/lib/patch_ruby/models/project_response.rb +++ b/lib/patch_ruby/models/project_response.rb @@ -61,7 +61,6 @@ def initialize(attributes = {}) if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::ProjectResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end - h[k.to_sym] = v } @@ -98,7 +97,6 @@ def list_invalid_properties def valid? return false if @success.nil? return false if @data.nil? - true end @@ -106,11 +104,10 @@ def valid? # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class && - success == o.success && - error == o.error && - data == o.data + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -137,7 +134,6 @@ def self.build_from_hash(attributes) # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -216,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index 824daea..482d0b1 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.0.0' + VERSION = '1.1.0' end diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb index c3edea8..523d0c1 100644 --- a/spec/integration/estimates_spec.rb +++ b/spec/integration/estimates_spec.rb @@ -1,10 +1,11 @@ RSpec.describe 'Estimates Integration' do - it 'supports create, retrieve and list' do - # Configure the Patch gem + before do Patch.configure do |config| config.access_token = ENV['PATCH_RUBY_API_KEY'] end + end + it 'supports create, retrieve and list' do create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100) estimate_id = create_estimate_response.data.id @@ -23,4 +24,15 @@ expect(estimates.length).not_to be_zero end + + it 'supports create with a project-id' do + retrieve_projects_response = Patch::Project.retrieve_projects(page: 1) + project_id = retrieve_projects_response.data.first.id + create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100, project_id: project_id) + estimate_id = create_estimate_response.data.id + + expect(create_estimate_response.success).to eq true + expect(create_estimate_response.data.order.id).not_to be_nil + expect(create_estimate_response.data.order.mass_g).to eq(100) + end end diff --git a/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index 2511e3b..2c44fef 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -25,6 +25,28 @@ expect(orders.length).not_to be_zero end + it 'supports create with a project-id' do + retrieve_projects_response = Patch::Project.retrieve_projects(page: 1) + project_id = retrieve_projects_response.data.first.id + + create_order_response = Patch::Order.create_order(mass_g: 100, project_id: project_id) + + expect(create_order_response.success).to eq true + expect(create_order_response.data.id).not_to be_nil + expect(create_order_response.data.mass_g).to eq(100) + end + + it 'supports create with metadata' do + metadata = { user: 'john doe' } + + create_order_response = Patch::Order.create_order(mass_g: 100, metadata: metadata) + + expect(create_order_response.success).to eq true + expect(create_order_response.data.id).not_to be_nil + expect(create_order_response.data.mass_g).to eq(100) + expect(create_order_response.data.metadata).to eq(metadata) + end + it 'supports place and cancel for orders created via an estimate' do create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100) order_to_place_id = create_estimate_to_place_response.data.order.id