Skip to content

Commit 4cc8d07

Browse files
authored
Add technology_type index method (#48)
1 parent ccfdab0 commit 4cc8d07

13 files changed

+449
-34
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.15.0] - 2021-10-04
9+
10+
### Added
11+
12+
- Added the ability to fetch project technology types via `Patch::TechnologyType.retrieve_technology_types()`
13+
814
## [1.14.0] - 2021-09-21
915

1016
### Added

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.14.0)
4+
patch_ruby (1.15.0)
55
typhoeus (~> 1.0, >= 1.0.1)
66

77
GEM

lib/patch_ruby.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@
4646
require 'patch_ruby/models/sdg'
4747
require 'patch_ruby/models/standard'
4848
require 'patch_ruby/models/technology_type'
49+
require 'patch_ruby/models/technology_type_list_response'
4950

5051
# APIs
5152
require 'patch_ruby/api/estimates_api'
5253
require 'patch_ruby/api/orders_api'
5354
require 'patch_ruby/api/preferences_api'
5455
require 'patch_ruby/api/projects_api'
56+
require 'patch_ruby/api/technology_types_api'
5557

5658
module Patch
5759
class << self
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
=begin
2+
#Patch API V1
3+
4+
#The core API used to integrate with Patch's service
5+
6+
The version of the OpenAPI document: v1
7+
Contact: developers@usepatch.com
8+
Generated by: https://openapi-generator.tech
9+
OpenAPI Generator version: 5.2.1
10+
11+
=end
12+
13+
require 'cgi'
14+
15+
module Patch
16+
class TechnologyTypesApi
17+
OPERATIONS = [
18+
:retrieve_technology_types,
19+
]
20+
21+
attr_accessor :api_client
22+
23+
def initialize(api_client = ApiClient.default)
24+
@api_client = api_client
25+
end
26+
# Retrieves the list of technology_types
27+
# Retrieves a list of all technology_types.
28+
# @param [Hash] opts the optional parameters
29+
# @return [TechnologyTypeListResponse]
30+
def retrieve_technology_types(opts = {})
31+
32+
data, _status_code, _headers = retrieve_technology_types_with_http_info(opts)
33+
data
34+
end
35+
36+
# Retrieves the list of technology_types
37+
# Retrieves a list of all technology_types.
38+
# @param [Hash] opts the optional parameters
39+
# @return [Array<(TechnologyTypeListResponse, Integer, Hash)>] TechnologyTypeListResponse data, response status code and response headers
40+
def retrieve_technology_types_with_http_info(opts = {})
41+
if @api_client.config.debugging
42+
@api_client.config.logger.debug 'Calling API: TechnologyTypesApi.retrieve_technology_types ...'
43+
end
44+
# resource path
45+
local_var_path = '/v1/projects/technology_types'
46+
47+
# query parameters
48+
query_params = opts[:query_params] || {}
49+
50+
# header parameters
51+
header_params = opts[:header_params] || {}
52+
# HTTP header 'Accept' (if needed)
53+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
54+
55+
# form parameters
56+
form_params = opts[:form_params] || {}
57+
58+
# http body (model)
59+
post_body = opts[:debug_body]
60+
61+
# return_type
62+
return_type = opts[:debug_return_type] || 'TechnologyTypeListResponse'
63+
64+
# auth_names
65+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
66+
67+
new_options = opts.merge(
68+
:operation => :"TechnologyTypesApi.retrieve_technology_types",
69+
:header_params => header_params,
70+
:query_params => query_params,
71+
:form_params => form_params,
72+
:body => post_body,
73+
:auth_names => auth_names,
74+
:return_type => return_type
75+
)
76+
77+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
78+
if @api_client.config.debugging
79+
@api_client.config.logger.debug "API called: TechnologyTypesApi#retrieve_technology_types\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
80+
end
81+
return data, status_code, headers
82+
end
83+
end
84+
end

lib/patch_ruby/api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ApiClient
3131
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
3232
def initialize(config = Configuration.default)
3333
@config = config
34-
@user_agent = "patch-ruby/1.14.0"
34+
@user_agent = "patch-ruby/1.15.0"
3535
@default_headers = {
3636
'Content-Type' => 'application/json',
3737
'User-Agent' => @user_agent

lib/patch_ruby/models/parent_technology_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
require 'time'
1515

1616
module Patch
17+
# An object containing the parent technology type's name and slug.
1718
class ParentTechnologyType
1819
# Unique identifier for this type of technology.
1920
attr_accessor :slug

lib/patch_ruby/models/project.rb

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class Project
2727
# The description of the project.
2828
attr_accessor :description
2929

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

33-
# The mechanism of the project. removal or avoidance.
33+
# The mechanism of the project. Either removal or avoidance.
3434
attr_accessor :mechanism
3535

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

66-
attr_accessor :technology_type
67-
68-
# A short description of the project
66+
# A short description of the project.
6967
attr_accessor :tagline
7068

69+
attr_accessor :technology_type
70+
7171
class EnumAttributeValidator
7272
attr_reader :datatype
7373
attr_reader :allowable_values
@@ -109,8 +109,8 @@ def self.attribute_map
109109
:'remaining_mass_g' => :'remaining_mass_g',
110110
:'standard' => :'standard',
111111
:'sdgs' => :'sdgs',
112-
:'technology_type' => :'technology_type',
113-
:'tagline' => :'tagline'
112+
:'tagline' => :'tagline',
113+
:'technology_type' => :'technology_type'
114114
}
115115
end
116116

@@ -138,8 +138,8 @@ def self.openapi_types
138138
:'remaining_mass_g' => :'Integer',
139139
:'standard' => :'Standard',
140140
:'sdgs' => :'Array<Sdg>',
141-
:'technology_type' => :'TechnologyType',
142-
:'tagline' => :'String'
141+
:'tagline' => :'String',
142+
:'technology_type' => :'TechnologyType'
143143
}
144144
end
145145

@@ -152,7 +152,6 @@ def self.openapi_nullable
152152
:'photos',
153153
:'standard',
154154
:'sdgs',
155-
:'tagline'
156155
])
157156
end
158157

@@ -251,13 +250,13 @@ def initialize(attributes = {})
251250
end
252251
end
253252

254-
if attributes.key?(:'technology_type')
255-
self.technology_type = attributes[:'technology_type']
256-
end
257-
258253
if attributes.key?(:'tagline')
259254
self.tagline = attributes[:'tagline']
260255
end
256+
257+
if attributes.key?(:'technology_type')
258+
self.technology_type = attributes[:'technology_type']
259+
end
261260
end
262261

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

298+
if @technology_type.nil?
299+
invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
300+
end
301+
299302
invalid_properties
300303
end
301304

@@ -306,27 +309,16 @@ def valid?
306309
return false if @production.nil?
307310
return false if @name.nil?
308311
return false if @description.nil?
309-
type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
310-
return false unless type_validator.valid?(@type)
311312
mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
312313
return false unless mechanism_validator.valid?(@mechanism)
313314
return false if @country.nil?
314315
return false if @developer.nil?
315316
return false if @average_price_per_tonne_cents_usd.nil?
316317
return false if @remaining_mass_g.nil?
318+
return false if @technology_type.nil?
317319
true
318320
end
319321

320-
# Custom attribute writer method checking allowed values (enum).
321-
# @param [Object] type Object to be assigned
322-
def type=(type)
323-
validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
324-
unless validator.valid?(type)
325-
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
326-
end
327-
@type = type
328-
end
329-
330322
# Custom attribute writer method checking allowed values (enum).
331323
# @param [Object] mechanism Object to be assigned
332324
def mechanism=(mechanism)
@@ -358,8 +350,8 @@ def ==(o)
358350
remaining_mass_g == o.remaining_mass_g &&
359351
standard == o.standard &&
360352
sdgs == o.sdgs &&
361-
technology_type == o.technology_type &&
362-
tagline == o.tagline
353+
tagline == o.tagline &&
354+
technology_type == o.technology_type
363355
end
364356

365357
# @see the `==` method
@@ -371,7 +363,7 @@ def eql?(o)
371363
# Calculates hash code according to all attributes.
372364
# @return [Integer] Hash code
373365
def hash
374-
[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
366+
[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
375367
end
376368

377369
# Builds the object from hash

lib/patch_ruby/models/technology_type.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
require 'time'
1515

1616
module Patch
17+
# An object containing the technology type's name, slug and parent_technology_type.
1718
class TechnologyType
1819
# Unique identifier for this type of technology.
1920
attr_accessor :slug
2021

21-
# Name of this technology type.
22+
# Display name of this technology type.
2223
attr_accessor :name
2324

2425
attr_accessor :parent_technology_type
@@ -96,12 +97,22 @@ def initialize(attributes = {})
9697
# @return Array for valid properties with the reasons
9798
def list_invalid_properties
9899
invalid_properties = Array.new
100+
if @slug.nil?
101+
invalid_properties.push('invalid value for "slug", slug cannot be nil.')
102+
end
103+
104+
if @name.nil?
105+
invalid_properties.push('invalid value for "name", name cannot be nil.')
106+
end
107+
99108
invalid_properties
100109
end
101110

102111
# Check to see if the all the properties in the model are valid
103112
# @return true if the model is valid
104113
def valid?
114+
return false if @slug.nil?
115+
return false if @name.nil?
105116
true
106117
end
107118

0 commit comments

Comments
 (0)