Class: Io::Flow::V0::Clients::Tiers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Tiers
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(organization, id) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Tiers
constructor
A new instance of Tiers.
- #post(organization, tier_form) ⇒ Object
- #put_by_id(organization, id, tier_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Tiers
Returns a new instance of Tiers.
4860 4861 4862 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4860 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
4915 4916 4917 4918 4919 4920 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4915 def delete_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(id)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4864 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) 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) }), :direction => (x = opts.delete(:direction); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LaneDirection) ? x : ::Io::Flow::V0::Models::LaneDirection.apply(x)).value), :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', x, String)), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', 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? ? "name" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/tiers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Tier.new(x) } end |
#get_by_id(organization, id) ⇒ Object
4900 4901 4902 4903 4904 4905 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4900 def get_by_id(organization, id) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Tier.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4887 def get_versions(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) 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) }), :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("/#{CGI.escape(organization)}/tiers/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierVersion.new(x) } end |
#post(organization, tier_form) ⇒ Object
4880 4881 4882 4883 4884 4885 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4880 def post(organization, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = tier_form; x.is_a?(::Io::Flow::V0::Models::TierForm) ? x : ::Io::Flow::V0::Models::TierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers").with_json(tier_form.to_json).post ::Io::Flow::V0::Models::Tier.new(r) end |
#put_by_id(organization, id, tier_form) ⇒ Object
4907 4908 4909 4910 4911 4912 4913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4907 def put_by_id(organization, id, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) (x = tier_form; x.is_a?(::Io::Flow::V0::Models::TierForm) ? x : ::Io::Flow::V0::Models::TierForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tiers/#{CGI.escape(id)}").with_json(tier_form.to_json).put ::Io::Flow::V0::Models::Tier.new(r) end |