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.
-
#get(incoming = {}) ⇒ Object
Search organizations.
-
#get_by_id(id) ⇒ Object
Returns information about a specific organization.
-
#get_countries_by_organization(organization) ⇒ 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_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.
Constructor Details
#initialize(client) ⇒ Organizations
Returns a new instance of Organizations.
1058 1059 1060 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1058 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
1110 1111 1112 1113 1114 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1110 def delete_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/organizations/#{CGI.escape(id)}").delete nil end |
#get(incoming = {}) ⇒ Object
Search organizations. Always paginated.
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1072 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.
1095 1096 1097 1098 1099 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1095 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_by_organization(organization) ⇒ 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.
1065 1066 1067 1068 1069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1065 def get_countries_by_organization(organization) HttpClient::Preconditions.assert_class('organization', organization, String) r = @client.request("/#{CGI.escape(organization)}/countries").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.
1117 1118 1119 1120 1121 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1117 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_versions(incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1124 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.
1088 1089 1090 1091 1092 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1088 def post(organization_form) HttpClient::Preconditions.assert_class('organization_form', organization_form, ::Io::Flow::V0::Models::OrganizationForm) 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.
1102 1103 1104 1105 1106 1107 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1102 def put_by_id(id, organization_put_form) HttpClient::Preconditions.assert_class('id', id, String) HttpClient::Preconditions.assert_class('organization_put_form', organization_put_form, ::Io::Flow::V0::Models::OrganizationPutForm) r = @client.request("/organizations/#{CGI.escape(id)}").with_json(organization_put_form.to_json).put ::Io::Flow::V0::Models::Organization.new(r) end |