Class: Io::Flow::V0::Clients::Organizations
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Organizations
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(id) ⇒ Object
Delete the organization with this id.
-
#delete_settings_and_regions_by_organization_id_and_id(organization_id, id) ⇒ Object
Removes the setting for this region for a specific organization.
-
#get(incoming = {}) ⇒ Object
Search organizations.
-
#get_by_id(id) ⇒ Object
Returns information about a specific organization.
-
#get_countries_and_destinations_by_organization(organization) ⇒ Object
List of all destination countries available for this organization, including countries within a world experience.
-
#get_countries_by_organization(organization, incoming = {}) ⇒ Object
The countries resources provides a unique list of all of the countries for which an experience exists.
-
#get_settings_and_currencies_by_organization_id(organization_id) ⇒ Object
Returns currencies for a specific organization.
-
#get_settings_and_regions_and_countries_and_available_by_organization_id(organization_id) ⇒ Object
Returns the list of enabled countries based on the region settings for a specific organization.
-
#get_settings_and_regions_by_organization_id(organization_id) ⇒ Object
Returns the region settings associated to a specific organization.
-
#get_versions(incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Organizations
constructor
A new instance of Organizations.
-
#post(organization_form) ⇒ Object
Create a new organization.
-
#put_by_id(id, organization_put_form) ⇒ Object
Update or create an organization with the specified id.
-
#put_settings_and_regions_by_organization_id(organization_id, region_setting_form) ⇒ Object
Updates or creates a region setting for a specific organization.
Constructor Details
#initialize(client) ⇒ Organizations
Returns a new instance of Organizations.
1271 1272 1273 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1271 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(id) ⇒ Object
Delete the organization with this id
1336 1337 1338 1339 1340 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1336 def delete_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/organizations/#{CGI.escape(id)}").delete nil end |
#delete_settings_and_regions_by_organization_id_and_id(organization_id, id) ⇒ Object
Removes the setting for this region for a specific organization
1365 1366 1367 1368 1369 1370 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1365 def delete_settings_and_regions_by_organization_id_and_id(organization_id, id) HttpClient::Preconditions.assert_class('organization_id', organization_id, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/organizations/#{CGI.escape(organization_id)}/settings/regions/#{CGI.escape(id)}").delete nil end |
#get(incoming = {}) ⇒ Object
Search organizations. Always paginated.
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1298 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :name => (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, String)), :environment => (x = opts.delete(:environment); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Environment) ? x : ::Io::Flow::V0::Models::Environment.apply(x)).value), :parent => (x = opts.delete(:parent); x.nil? ? nil : HttpClient::Preconditions.assert_class('parent', x, String)), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/organizations").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Organization.new(x) } end |
#get_by_id(id) ⇒ Object
Returns information about a specific organization.
1321 1322 1323 1324 1325 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1321 def get_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/organizations/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Organization.new(r) end |
#get_countries_and_destinations_by_organization(organization) ⇒ Object
List of all destination countries available for this organization, including countries within a world experience.
1291 1292 1293 1294 1295 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1291 def get_countries_and_destinations_by_organization(organization) HttpClient::Preconditions.assert_class('organization', organization, String) r = @client.request("/#{CGI.escape(organization)}/countries/destinations").get r.map { |x| ::Io::Flow::V0::Models::Country.new(x) } end |
#get_countries_by_organization(organization, incoming = {}) ⇒ Object
The countries resources provides a unique list of all of the countries for which an experience exists. We generate this list of countries by iterating through all of the experience regions, and collecting all of the countries.
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1278 def get_countries_by_organization(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :ip => (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)), :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/countries").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Country.new(x) } end |
#get_settings_and_currencies_by_organization_id(organization_id) ⇒ Object
Returns currencies for a specific organization.
1343 1344 1345 1346 1347 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1343 def get_settings_and_currencies_by_organization_id(organization_id) HttpClient::Preconditions.assert_class('organization_id', organization_id, String) r = @client.request("/organizations/#{CGI.escape(organization_id)}/settings/currencies").get r.map { |x| ::Io::Flow::V0::Models::Currency.new(x) } end |
#get_settings_and_regions_and_countries_and_available_by_organization_id(organization_id) ⇒ Object
Returns the list of enabled countries based on the region settings for a specific organization
1374 1375 1376 1377 1378 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1374 def get_settings_and_regions_and_countries_and_available_by_organization_id(organization_id) HttpClient::Preconditions.assert_class('organization_id', organization_id, String) r = @client.request("/organizations/#{CGI.escape(organization_id)}/settings/regions/countries/available").get r.map { |x| ::Io::Flow::V0::Models::Country.new(x) } end |
#get_settings_and_regions_by_organization_id(organization_id) ⇒ Object
Returns the region settings associated to a specific organization.
1350 1351 1352 1353 1354 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1350 def get_settings_and_regions_by_organization_id(organization_id) HttpClient::Preconditions.assert_class('organization_id', organization_id, String) r = @client.request("/organizations/#{CGI.escape(organization_id)}/settings/regions").get r.map { |x| ::Io::Flow::V0::Models::RegionSetting.new(x) } end |
#get_versions(incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1381 def get_versions(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :organization => (x = opts.delete(:organization); x.nil? ? nil : HttpClient::Preconditions.assert_class('organization', x, Array).map { |v| HttpClient::Preconditions.assert_class('organization', v, String) }), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/organizations/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::OrganizationVersion.new(x) } end |
#post(organization_form) ⇒ Object
Create a new organization.
1314 1315 1316 1317 1318 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1314 def post(organization_form) (x = organization_form; x.is_a?(::Io::Flow::V0::Models::OrganizationForm) ? x : ::Io::Flow::V0::Models::OrganizationForm.new(x)) r = @client.request("/organizations").with_json(organization_form.to_json).post ::Io::Flow::V0::Models::Organization.new(r) end |
#put_by_id(id, organization_put_form) ⇒ Object
Update or create an organization with the specified id.
1328 1329 1330 1331 1332 1333 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1328 def put_by_id(id, organization_put_form) HttpClient::Preconditions.assert_class('id', id, String) (x = organization_put_form; x.is_a?(::Io::Flow::V0::Models::OrganizationPutForm) ? x : ::Io::Flow::V0::Models::OrganizationPutForm.new(x)) r = @client.request("/organizations/#{CGI.escape(id)}").with_json(organization_put_form.to_json).put ::Io::Flow::V0::Models::Organization.new(r) end |
#put_settings_and_regions_by_organization_id(organization_id, region_setting_form) ⇒ Object
Updates or creates a region setting for a specific organization
1357 1358 1359 1360 1361 1362 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1357 def put_settings_and_regions_by_organization_id(organization_id, region_setting_form) HttpClient::Preconditions.assert_class('organization_id', organization_id, String) (x = region_setting_form; x.is_a?(::Io::Flow::V0::Models::RegionSettingForm) ? x : ::Io::Flow::V0::Models::RegionSettingForm.new(x)) r = @client.request("/organizations/#{CGI.escape(organization_id)}/settings/regions").with_json(region_setting_form.to_json).put ::Io::Flow::V0::Models::RegionSetting.new(r) end |