Class: Io::Flow::V0::Clients::TierDefaults
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::TierDefaults
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #get(organization, incoming = {}) ⇒ Object
- #get_by_id(organization, id) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ TierDefaults
constructor
A new instance of TierDefaults.
- #post(organization, tier_default_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ TierDefaults
3171 3172 3173 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3171 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3175 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, Array).map { |v| HttpClient::Preconditions.assert_class('experience', 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? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/tier_defaults").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierDefault.new(x) } end |
#get_by_id(organization, id) ⇒ Object
3196 3197 3198 3199 3200 3201 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3196 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)}/tier_defaults/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::TierDefault.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3203 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_default => (x = opts.delete(:tier_default); x.nil? ? nil : HttpClient::Preconditions.assert_class('tier_default', x, Array).map { |v| HttpClient::Preconditions.assert_class('tier_default', 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)}/tier_defaults/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TierDefaultVersion.new(x) } end |
#post(organization, tier_default_form) ⇒ Object
3189 3190 3191 3192 3193 3194 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3189 def post(organization, tier_default_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = tier_default_form; x.is_a?(::Io::Flow::V0::Models::TierDefaultForm) ? x : ::Io::Flow::V0::Models::TierDefaultForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/tier_defaults").with_json(tier_default_form.to_json).post ::Io::Flow::V0::Models::TierDefault.new(r) end |