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.
1308 1309 1310 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1308 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
1348 1349 1350 1351 1352 1353 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1348 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
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1312 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
1333 1334 1335 1336 1337 1338 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1333 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
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1355 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
1326 1327 1328 1329 1330 1331 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1326 def post(organization, targeting_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('targeting_form', targeting_form, ::Io::Flow::V0::Models::TargetingForm) 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
1340 1341 1342 1343 1344 1345 1346 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1340 def put_by_key(organization, key, targeting_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) HttpClient::Preconditions.assert_class('targeting_form', targeting_form, ::Io::Flow::V0::Models::TargetingForm) 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 |