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.
2804 2805 2806 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2804 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(organization, id) ⇒ Object
2844 2845 2846 2847 2848 2849 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2844 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
2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2808 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) }), :experience => (x = opts.delete(:experience); x.nil? ? nil : HttpClient::Preconditions.assert_class('experience', 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("/#{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
2829 2830 2831 2832 2833 2834 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2829 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
2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2851 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) }), :tier => (x = opts.delete(:tier); x.nil? ? nil : HttpClient::Preconditions.assert_class('tier', x, Array).map { |v| HttpClient::Preconditions.assert_class('tier', 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
2822 2823 2824 2825 2826 2827 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2822 def post(organization, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('tier_form', tier_form, ::Io::Flow::V0::Models::TierForm) 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
2836 2837 2838 2839 2840 2841 2842 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2836 def put_by_id(organization, id, tier_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('id', id, String) HttpClient::Preconditions.assert_class('tier_form', tier_form, ::Io::Flow::V0::Models::TierForm) 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 |