Class: Io::Flow::V0::Clients::AbandonedOrderPromotions

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AbandonedOrderPromotions

Returns a new instance of AbandonedOrderPromotions.



5139
5140
5141
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5139

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



5179
5180
5181
5182
5183
5184
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5179

def delete_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/promotions/#{CGI.escape(id)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object



5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5143

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) }),
    :name => (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, Array).map { |v| HttpClient::Preconditions.assert_class('name', 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? ? "name" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/promotions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::AbandonedOrderPromotion.new(x) }
end

#get_by_id(organization, id) ⇒ Object



5164
5165
5166
5167
5168
5169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5164

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)}/marketing/abandoned/order/promotions/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::AbandonedOrderPromotion.new(r)
end

#post(organization, abandoned_order_promotion_form) ⇒ Object



5157
5158
5159
5160
5161
5162
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5157

def post(organization, abandoned_order_promotion_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = abandoned_order_promotion_form; x.is_a?(::Io::Flow::V0::Models::AbandonedOrderPromotionForm) ? x : ::Io::Flow::V0::Models::AbandonedOrderPromotionForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/promotions").with_json(abandoned_order_promotion_form.to_json).post
  ::Io::Flow::V0::Models::AbandonedOrderPromotion.new(r)
end

#put_by_id(organization, id, abandoned_order_promotion_form) ⇒ Object



5171
5172
5173
5174
5175
5176
5177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5171

def put_by_id(organization, id, abandoned_order_promotion_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = abandoned_order_promotion_form; x.is_a?(::Io::Flow::V0::Models::AbandonedOrderPromotionForm) ? x : ::Io::Flow::V0::Models::AbandonedOrderPromotionForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/promotions/#{CGI.escape(id)}").with_json(abandoned_order_promotion_form.to_json).put
  ::Io::Flow::V0::Models::AbandonedOrderPromotion.new(r)
end