Class: Io::Flow::V0::Clients::Refunds

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Refunds

Returns a new instance of Refunds.



3583
3584
3585
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3583

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

Instance Method Details

#delete_identifiers_by_key_and_identifier(organization, key, identifier) ⇒ Object



3670
3671
3672
3673
3674
3675
3676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3670

def delete_identifiers_by_key_and_identifier(organization, key, identifier)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  HttpClient::Preconditions.assert_class('identifier', identifier, String)
  r = @client.request("/#{CGI.escape(organization)}/refunds/#{CGI.escape(key)}/identifiers/#{CGI.escape(identifier)}").delete
  nil
end

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



3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3587

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) }),
    :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, String)),
    :authorization_id => (x = opts.delete(:authorization_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_id', x, String)),
    :authorization_key => (x = opts.delete(:authorization_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_key', x, String)),
    :capture_id => (x = opts.delete(:capture_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_id', x, String)),
    :capture_key => (x = opts.delete(:capture_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('capture_key', x, 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)}/refunds").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Refund.new(x) }
end

#get_by_key(organization, key) ⇒ Object

Returns information about a specific refund.



3638
3639
3640
3641
3642
3643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3638

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)}/refunds/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::Refund.new(r)
end

#get_identifiers_by_key(organization, key, incoming = {}) ⇒ Object



3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3645

def get_identifiers_by_key(organization, key, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, 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) }),
    :identifier => (x = opts.delete(:identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifier', x, 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)}/refunds/#{CGI.escape(key)}/identifiers").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::RefundIdentifier.new(x) }
end

#get_summary_by_order_number(organization, order_number) ⇒ Object

Returns a refund order summary for the specified order.



3615
3616
3617
3618
3619
3620
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3615

def get_summary_by_order_number(organization, order_number)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('order_number', order_number, String)
  r = @client.request("/#{CGI.escape(organization)}/refunds/summary/#{CGI.escape(order_number)}").get
  ::Io::Flow::V0::Models::RefundOrderSummary.new(r)
end

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

Provides visibility into recent changes of each object, including deletion



3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3623

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, Integer) }),
    :refund_id => (x = opts.delete(:refund_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('refund_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('refund_id', 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)}/refunds/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::RefundVersion.new(x) }
end

#post(organization, refund_form) ⇒ Object

Create a new refund.



3607
3608
3609
3610
3611
3612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3607

def post(organization, refund_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = refund_form; x.is_a?(::Io::Flow::V0::Models::RefundForm) ? x : ::Io::Flow::V0::Models::RefundForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/refunds").with_json(refund_form.to_json).post
  ::Io::Flow::V0::Models::Refund.new(r)
end

#put_identifiers_by_key_and_identifier(organization, key, identifier, identifier_form) ⇒ Object

Create a new identifier for this refund



3661
3662
3663
3664
3665
3666
3667
3668
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3661

def put_identifiers_by_key_and_identifier(organization, key, identifier, identifier_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  HttpClient::Preconditions.assert_class('identifier', identifier, String)
  (x = identifier_form; x.is_a?(::Io::Flow::V0::Models::IdentifierForm) ? x : ::Io::Flow::V0::Models::IdentifierForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/refunds/#{CGI.escape(key)}/identifiers/#{CGI.escape(identifier)}").with_json(identifier_form.to_json).put
  ::Io::Flow::V0::Models::RefundIdentifier.new(r)
end