Class: Io::Flow::V0::Clients::AbandonedOrderSettings

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AbandonedOrderSettings

Returns a new instance of AbandonedOrderSettings.



5428
5429
5430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5428

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

Instance Method Details

#delete(organization) ⇒ Object



5466
5467
5468
5469
5470
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5466

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

#get(organization) ⇒ Object



5432
5433
5434
5435
5436
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5432

def get(organization)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/settings").get
  ::Io::Flow::V0::Models::AbandonedOrderSettings.new(r)
end

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



5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5438

def post(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :delay_time => HttpClient::Preconditions.assert_class('delay_time', (x = opts.delete(:delay_time); x.nil? ? 30 : x), Integer),
    :delay_unit => (x = (x = opts.delete(:delay_unit); x.nil? ? "minute" : x); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x)).value,
    :frequency_time => HttpClient::Preconditions.assert_class('frequency_time', (x = opts.delete(:frequency_time); x.nil? ? 24 : x), Integer),
    :frequency_unit => (x = (x = opts.delete(:frequency_unit); x.nil? ? "hour" : x); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x)).value,
    :status => (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::AbandonedOrderSettingStatus) ? x : ::Io::Flow::V0::Models::AbandonedOrderSettingStatus.apply(x)).value
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/settings").with_query(query).post
  ::Io::Flow::V0::Models::AbandonedOrderSettings.new(r)
end

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



5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5452

def put(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :delay_time => HttpClient::Preconditions.assert_class('delay_time', opts.delete(:delay_time), Integer),
    :delay_unit => (x = opts.delete(:delay_unit); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x)).value,
    :frequency_time => HttpClient::Preconditions.assert_class('frequency_time', opts.delete(:frequency_time), Integer),
    :frequency_unit => (x = opts.delete(:frequency_unit); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x)).value,
    :status => (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::AbandonedOrderSettingStatus) ? x : ::Io::Flow::V0::Models::AbandonedOrderSettingStatus.apply(x)).value
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/marketing/abandoned/order/settings").with_query(query).put
  ::Io::Flow::V0::Models::AbandonedOrderSettings.new(r)
end