Skip to content

Commit

Permalink
Add technology_type index method (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinjm authored Oct 4, 2021
1 parent ccfdab0 commit 4cc8d07
Show file tree
Hide file tree
Showing 13 changed files with 449 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [1.15.0] - 2021-10-04

### Added

- Added the ability to fetch project technology types via `Patch::TechnologyType.retrieve_technology_types()`

## [1.14.0] - 2021-09-21

### Added
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
patch_ruby (1.14.0)
patch_ruby (1.15.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
2 changes: 2 additions & 0 deletions lib/patch_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
require 'patch_ruby/models/sdg'
require 'patch_ruby/models/standard'
require 'patch_ruby/models/technology_type'
require 'patch_ruby/models/technology_type_list_response'

# APIs
require 'patch_ruby/api/estimates_api'
require 'patch_ruby/api/orders_api'
require 'patch_ruby/api/preferences_api'
require 'patch_ruby/api/projects_api'
require 'patch_ruby/api/technology_types_api'

module Patch
class << self
Expand Down
84 changes: 84 additions & 0 deletions lib/patch_ruby/api/technology_types_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=begin
#Patch API V1
#The core API used to integrate with Patch's service
The version of the OpenAPI document: v1
Contact: [email protected]
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.2.1
=end

require 'cgi'

module Patch
class TechnologyTypesApi
OPERATIONS = [
:retrieve_technology_types,
]

attr_accessor :api_client

def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Retrieves the list of technology_types
# Retrieves a list of all technology_types.
# @param [Hash] opts the optional parameters
# @return [TechnologyTypeListResponse]
def retrieve_technology_types(opts = {})

data, _status_code, _headers = retrieve_technology_types_with_http_info(opts)
data
end

# Retrieves the list of technology_types
# Retrieves a list of all technology_types.
# @param [Hash] opts the optional parameters
# @return [Array<(TechnologyTypeListResponse, Integer, Hash)>] TechnologyTypeListResponse data, response status code and response headers
def retrieve_technology_types_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TechnologyTypesApi.retrieve_technology_types ...'
end
# resource path
local_var_path = '/v1/projects/technology_types'

# 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] || 'TechnologyTypeListResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer_auth']

new_options = opts.merge(
:operation => :"TechnologyTypesApi.retrieve_technology_types",
: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: TechnologyTypesApi#retrieve_technology_types\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
2 changes: 1 addition & 1 deletion lib/patch_ruby/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.14.0"
@user_agent = "patch-ruby/1.15.0"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
Expand Down
1 change: 1 addition & 0 deletions lib/patch_ruby/models/parent_technology_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require 'time'

module Patch
# An object containing the parent technology type's name and slug.
class ParentTechnologyType
# Unique identifier for this type of technology.
attr_accessor :slug
Expand Down
50 changes: 21 additions & 29 deletions lib/patch_ruby/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Project
# The description of the project.
attr_accessor :description

# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Renewables, Soil.
# Deprecated. Favor the technology_type field instead.
attr_accessor :type

# The mechanism of the project. removal or avoidance.
# The mechanism of the project. Either removal or avoidance.
attr_accessor :mechanism

# The country of origin of the project.
Expand Down Expand Up @@ -63,11 +63,11 @@ class Project
# An array returning the UN Sustainable Development Goals associated with this project.
attr_accessor :sdgs

attr_accessor :technology_type

# A short description of the project
# A short description of the project.
attr_accessor :tagline

attr_accessor :technology_type

class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
Expand Down Expand Up @@ -109,8 +109,8 @@ def self.attribute_map
:'remaining_mass_g' => :'remaining_mass_g',
:'standard' => :'standard',
:'sdgs' => :'sdgs',
:'technology_type' => :'technology_type',
:'tagline' => :'tagline'
:'tagline' => :'tagline',
:'technology_type' => :'technology_type'
}
end

Expand Down Expand Up @@ -138,8 +138,8 @@ def self.openapi_types
:'remaining_mass_g' => :'Integer',
:'standard' => :'Standard',
:'sdgs' => :'Array<Sdg>',
:'technology_type' => :'TechnologyType',
:'tagline' => :'String'
:'tagline' => :'String',
:'technology_type' => :'TechnologyType'
}
end

Expand All @@ -152,7 +152,6 @@ def self.openapi_nullable
:'photos',
:'standard',
:'sdgs',
:'tagline'
])
end

Expand Down Expand Up @@ -251,13 +250,13 @@ def initialize(attributes = {})
end
end

if attributes.key?(:'technology_type')
self.technology_type = attributes[:'technology_type']
end

if attributes.key?(:'tagline')
self.tagline = attributes[:'tagline']
end

if attributes.key?(:'technology_type')
self.technology_type = attributes[:'technology_type']
end
end

# Show invalid properties with the reasons. Usually used together with valid?
Expand Down Expand Up @@ -296,6 +295,10 @@ def list_invalid_properties
invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.')
end

if @technology_type.nil?
invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
end

invalid_properties
end

Expand All @@ -306,27 +309,16 @@ def valid?
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", "renewables", "soil"])
return false unless type_validator.valid?(@type)
mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
return false unless mechanism_validator.valid?(@mechanism)
return false if @country.nil?
return false if @developer.nil?
return false if @average_price_per_tonne_cents_usd.nil?
return false if @remaining_mass_g.nil?
return false if @technology_type.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", "renewables", "soil"])
unless validator.valid?(type)
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
end
@type = type
end

# Custom attribute writer method checking allowed values (enum).
# @param [Object] mechanism Object to be assigned
def mechanism=(mechanism)
Expand Down Expand Up @@ -358,8 +350,8 @@ def ==(o)
remaining_mass_g == o.remaining_mass_g &&
standard == o.standard &&
sdgs == o.sdgs &&
technology_type == o.technology_type &&
tagline == o.tagline
tagline == o.tagline &&
technology_type == o.technology_type
end

# @see the `==` method
Expand All @@ -371,7 +363,7 @@ def eql?(o)
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs, technology_type, tagline].hash
[id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs, tagline, technology_type].hash
end

# Builds the object from hash
Expand Down
13 changes: 12 additions & 1 deletion lib/patch_ruby/models/technology_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
require 'time'

module Patch
# An object containing the technology type's name, slug and parent_technology_type.
class TechnologyType
# Unique identifier for this type of technology.
attr_accessor :slug

# Name of this technology type.
# Display name of this technology type.
attr_accessor :name

attr_accessor :parent_technology_type
Expand Down Expand Up @@ -96,12 +97,22 @@ def initialize(attributes = {})
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @slug.nil?
invalid_properties.push('invalid value for "slug", slug cannot be nil.')
end

if @name.nil?
invalid_properties.push('invalid value for "name", name 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 @slug.nil?
return false if @name.nil?
true
end

Expand Down
Loading

0 comments on commit 4cc8d07

Please sign in to comment.