Class: Gusto::Companies::LocationsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::LocationsClient
- Defined in:
- lib/fern_gusto/companies/locations/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
).
-
#get(location_id:, request_options: nil) ⇒ Object
api.companies.locations.get(location_id: “location_id”).
-
#get_minimum_wages(location_uuid:, effective_date: nil, request_options: nil) ⇒ Object
api.companies.locations.get_minimum_wages(location_uuid: “location_uuid”, effective_date: “2020-01-31”).
- #initialize(request_client:) ⇒ Gusto::Companies::LocationsClient constructor
-
#update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::LocationsClient
21 22 23 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 21 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
16 17 18 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 16 def request_client @request_client end |
Instance Method Details
#create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
)
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 94 def create(company_id:, phone_number:, street1:, street2: nil, city:, state:, zip:, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), phone_number: phone_number, street_1: street1, street_2: street2, city: city, state: state, zip: zip, country: country, mailing_address: mailing_address, filing_address: filing_address }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/locations" end Gusto::Locations::Location.from_json(json_object: response.body) end |
#get(location_id:, request_options: nil) ⇒ Object
api.companies.locations.get(location_id: “location_id”)
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 37 def get(location_id:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/locations/#{location_id}" end Gusto::Locations::Location.from_json(json_object: response.body) end |
#get_minimum_wages(location_uuid:, effective_date: nil, request_options: nil) ⇒ Object
api.companies.locations.get_minimum_wages(location_uuid: “location_uuid”, effective_date: “2020-01-31”)
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 186 def get_minimum_wages(location_uuid:, effective_date: nil, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "effective_date": effective_date }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/locations/#{location_uuid}/minimum_wages" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::MinimumWage.from_json(json_object: item) end end |
#update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) ⇒ Object
)
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/fern_gusto/companies/locations/client.rb', line 152 def update(location_id:, version:, phone_number: nil, street1: nil, street2: nil, city: nil, state: nil, zip: nil, country: nil, mailing_address: nil, filing_address: nil, request_options: nil) response = @request_client.conn.put do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), version: version, phone_number: phone_number, street_1: street1, street_2: street2, city: city, state: state, zip: zip, country: country, mailing_address: mailing_address, filing_address: filing_address }.compact req.url "#{@request_client.get_url(request_options: )}/v1/locations/#{location_id}" end Gusto::Locations::Location.from_json(json_object: response.body) end |