Class: Io::Flow::V0::Clients::Targetings
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Targetings
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Targetings
constructor
A new instance of Targetings.
- #post(organization, targeting_form) ⇒ Object
- #put_by_key(organization, key, targeting_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Targetings
Returns a new instance of Targetings.
2372 2373 2374 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2372 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
2426 2427 2428 2429 2430 2431 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2426 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/catalog/targetings/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2376 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', 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)}/catalog/targetings").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Targeting.new(x) } end |
#get_by_key(organization, key) ⇒ Object
2411 2412 2413 2414 2415 2416 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2411 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/catalog/targetings/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Targeting.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2397 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', 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)}/catalog/targetings/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::TargetingVersion.new(x) } end |
#post(organization, targeting_form) ⇒ Object
2390 2391 2392 2393 2394 2395 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2390 def post(organization, targeting_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = targeting_form; x.is_a?(::Io::Flow::V0::Models::TargetingForm) ? x : ::Io::Flow::V0::Models::TargetingForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/targetings").with_json(targeting_form.to_json).post ::Io::Flow::V0::Models::Targeting.new(r) end |
#put_by_key(organization, key, targeting_form) ⇒ Object
2418 2419 2420 2421 2422 2423 2424 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2418 def put_by_key(organization, key, targeting_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = targeting_form; x.is_a?(::Io::Flow::V0::Models::TargetingForm) ? x : ::Io::Flow::V0::Models::TargetingForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/catalog/targetings/#{CGI.escape(key)}").with_json(targeting_form.to_json).put ::Io::Flow::V0::Models::Targeting.new(r) end |