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.



5658
5659
5660
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5658

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



5698
5699
5700
5701
5702
5703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5698

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



5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5662

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



5683
5684
5685
5686
5687
5688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5683

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



5676
5677
5678
5679
5680
5681
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5676

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



5690
5691
5692
5693
5694
5695
5696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5690

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