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.
2217 2218 2219 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2217 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
2271 2272 2273 2274 2275 2276 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2271 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
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2221 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
2256 2257 2258 2259 2260 2261 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2256 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
2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2242 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
2235 2236 2237 2238 2239 2240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2235 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
2263 2264 2265 2266 2267 2268 2269 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2263 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 |