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.
1277 1278 1279 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1277 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
1317 1318 1319 1320 1321 1322 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1317 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
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1281 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
1302 1303 1304 1305 1306 1307 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1302 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
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1324 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
1295 1296 1297 1298 1299 1300 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1295 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
1309 1310 1311 1312 1313 1314 1315 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 1309 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 |