From efe1b4ca050d3676b6a4c2c945497a9d999ad4d7 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 2 Feb 2022 16:15:54 -0800 Subject: [PATCH] Remove unused preferences files + update README (#56) * Clean-up for preferences * Update PR template --- .github/PULL_REQUEST_TEMPLATE.md | 1 + Gemfile.lock | 2 +- README.md | 27 --- lib/patch_ruby/api/preferences_api.rb | 284 -------------------------- lib/patch_ruby/api_client.rb | 2 +- lib/patch_ruby/version.rb | 2 +- 6 files changed, 4 insertions(+), 314 deletions(-) delete mode 100644 lib/patch_ruby/api/preferences_api.rb diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cb9ce56..b960d49 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,4 +12,5 @@ - [ ] Have you built the gem locally and made queries against it successfully? - [ ] Did you update the changelog? - [ ] Did you bump the package version [in the code generator](https://github.com/patch-technology/client-code-generation/blob/main/configs/ruby-config.json#L11-L12)? +- [ ] If endpoints were removed, did you manually remove the corresponding files? (this should be rare) - [ ] For breaking changes, did you plan for the release of the new SDK versions and deploy the API to production? diff --git a/Gemfile.lock b/Gemfile.lock index 713daf2..07aa825 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.17.0) + patch_ruby (1.17.1) typhoeus (~> 1.0, >= 1.0.1) GEM diff --git a/README.md b/README.md index 9f31cc9..c6ee22e 100644 --- a/README.md +++ b/README.md @@ -188,33 +188,6 @@ Patch::Project.retrieve_projects(type: type) minimum_available_mass = 100 Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass) ``` - -### Preferences - -Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](https://dashboard.patch.io/projects). - -[API Reference](https://docs.patch.io/#/?id=preferences) - -#### Examples - -```ruby -# Create a preference -project_id = 'pro_test_1234' # Pass in the project_id for your preference -Patch::Preference.create_preference(project_id: project_id) - -# Retrieve a preference -preference_id = 'pre_test_1234' # Pass in the preferences's id -Patch::Preference.retrieve_preference(preference_id) - -# Delete a preference -preference_id = 'pre_test_1234' # Pass in the preferences's id -Patch::Preference.delete_preference(preference_id) - -# Retrieve a list of preferences -page = 1 # Pass in which page of preferences you'd like -Patch::Preference.retrieve_preferences(page: page) -``` - ## Contributing While we value open-source contributions to this SDK, the core of this library is generated programmatically. Complex additions made directly to the library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us! diff --git a/lib/patch_ruby/api/preferences_api.rb b/lib/patch_ruby/api/preferences_api.rb deleted file mode 100644 index 9b10924..0000000 --- a/lib/patch_ruby/api/preferences_api.rb +++ /dev/null @@ -1,284 +0,0 @@ -=begin -#Patch API V1 - -#The core API used to integrate with Patch's service - -The version of the OpenAPI document: v1 -Contact: developers@usepatch.com -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.2.1 - -=end - -require 'cgi' - -module Patch - class PreferencesApi - OPERATIONS = [ - :create_preference, - :delete_preference, - :retrieve_preference, - :retrieve_preferences, - ] - - attr_accessor :api_client - - 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] - # @param [Hash] opts the optional parameters - # @return [PreferenceResponse] - def create_preference(create_preference_request = {}, opts = {}) - _create_preference_request = Patch::CreatePreferenceRequest.new(create_preference_request) - data, _status_code, _headers = create_preference_with_http_info(_create_preference_request, opts) - data - 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] - # @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 = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: PreferencesApi.create_preference ...' - end - # verify the required parameter 'create_preference_request' is set - 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' - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) - - # form parameters - form_params = opts[:form_params] || {} - - # http body (model) - post_body = opts[:debug_body] || @api_client.object_to_http_body(create_preference_request) - - # return_type - return_type = opts[:debug_return_type] || 'PreferenceResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"PreferencesApi.create_preference", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PreferencesApi#create_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - 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] - # @param [Hash] opts the optional parameters - # @return [PreferenceResponse] - def delete_preference(id, opts = {}) - - data, _status_code, _headers = delete_preference_with_http_info(id, opts) - data - 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] - # @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 = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: PreferencesApi.delete_preference ...' - end - # verify the required parameter 'id' is set - 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)) - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) - - # form parameters - form_params = opts[:form_params] || {} - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'PreferenceResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"PreferencesApi.delete_preference", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PreferencesApi#delete_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Retrieve the preference - # 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 = {}) - - data, _status_code, _headers = retrieve_preference_with_http_info(id, opts) - data - end - - # Retrieve the preference - # 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 = {}) - if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preference ...' - end - # verify the required parameter 'id' is set - 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)) - - # query parameters - query_params = opts[:query_params] || {} - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) - - # form parameters - form_params = opts[:form_params] || {} - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'PreferenceResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"PreferencesApi.retrieve_preference", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - 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. - # @param [Hash] opts the optional parameters - # @option opts [Integer] :page - # @return [PreferenceListResponse] - def retrieve_preferences(opts = {}) - - data, _status_code, _headers = retrieve_preferences_with_http_info(opts) - data - 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. - # @param [Hash] opts the optional parameters - # @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 - @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preferences ...' - end - # resource path - local_var_path = '/v1/preferences' - - # query parameters - query_params = opts[:query_params] || {} - query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? - - # header parameters - header_params = opts[:header_params] || {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/json']) - - # form parameters - form_params = opts[:form_params] || {} - - # http body (model) - post_body = opts[:debug_body] - - # return_type - return_type = opts[:debug_return_type] || 'PreferenceListResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"PreferencesApi.retrieve_preferences", - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => return_type - ) - - data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - end -end diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 6e926fb..613dd81 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -31,7 +31,7 @@ class ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config - @user_agent = "patch-ruby/1.17.0" + @user_agent = "patch-ruby/1.17.1" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index 5f175e5..5ec0455 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.17.0' + VERSION = '1.17.1' end