Class: Io::Flow::V0::Clients::Authorizations
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Authorizations
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_key(organization, key) ⇒ Object
Deprecated.
- #get(organization, incoming = {}) ⇒ Object
-
#get_by_key(organization, key, incoming = {}) ⇒ Object
Returns information about a specific authorization.
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Authorizations
constructor
A new instance of Authorizations.
-
#post(organization, authorization_form, incoming = {}) ⇒ Object
Create a new authorization.
-
#post_card(organization, card_authorization_form) ⇒ Object
Create a new card authorization using card details, or the token of a previously tokenized card.
-
#post_online(organization, authorization_form) ⇒ Object
Create a new online authorization.
-
#put_by_key(organization, key, authorization_form, incoming = {}) ⇒ Object
Copies an existing card authorization and authorizes funds using the saved credit card information from the source authorization.
-
#put_value_by_key(organization, key, authorization_value_form, incoming = {}) ⇒ Object
Updates the value of the authorization, or returns the authorization as-is if the value is the same.
Constructor Details
#initialize(client) ⇒ Authorizations
Returns a new instance of Authorizations.
2810 2811 2812 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2810 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
Deprecated. This end point no longer deletes an authorization and is implemented by creating a reversal for the remaining balance on the auth.
2903 2904 2905 2906 2907 2908 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2903 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)}/authorizations/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2814 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) }), :order_number => (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', 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), :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/authorizations").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Authorization.from_json(x) } end |
#get_by_key(organization, key, incoming = {}) ⇒ Object
Returns information about a specific authorization.
2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2875 def get_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 = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/authorizations/#{CGI.escape(key)}").with_query(query).get ::Io::Flow::V0::Models::Authorization.from_json(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2860 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) }), :authorization_id => (x = opts.delete(:authorization_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('authorization_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)}/authorizations/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::AuthorizationVersion.new(x) } end |
#post(organization, authorization_form, incoming = {}) ⇒ Object
Create a new authorization.
2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2831 def post(organization, , incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } (x = ; x.is_a?(::Io::Flow::V0::Models::AuthorizationForm) ? x : ::Io::Flow::V0::Models::AuthorizationForm.from_json(x)) r = @client.request("/#{CGI.escape(organization)}/authorizations").with_query(query).with_json(.to_json).post ::Io::Flow::V0::Models::Authorization.from_json(r) end |
#post_card(organization, card_authorization_form) ⇒ Object
Create a new card authorization using card details, or the token of a previously tokenized card.
2844 2845 2846 2847 2848 2849 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2844 def post_card(organization, ) HttpClient::Preconditions.assert_class('organization', organization, String) (x = ; x.is_a?(::Io::Flow::V0::Models::CardAuthorizationForm) ? x : ::Io::Flow::V0::Models::CardAuthorizationForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/authorizations/card").with_json(.to_json).post ::Io::Flow::V0::Models::CardAuthorization.new(r) end |
#post_online(organization, authorization_form) ⇒ Object
Create a new online authorization.
2852 2853 2854 2855 2856 2857 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2852 def post_online(organization, ) HttpClient::Preconditions.assert_class('organization', organization, String) (x = ; x.is_a?(::Io::Flow::V0::Models::AuthorizationForm) ? x : ::Io::Flow::V0::Models::AuthorizationForm.from_json(x)) r = @client.request("/#{CGI.escape(organization)}/authorizations/online").with_json(.to_json).post ::Io::Flow::V0::Models::OnlineAuthorization.new(r) end |
#put_by_key(organization, key, authorization_form, incoming = {}) ⇒ Object
Copies an existing card authorization and authorizes funds using the saved credit card information from the source authorization. Multiple requests using the same key are idempotent.
2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2889 def put_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 = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } (x = ; x.is_a?(::Io::Flow::V0::Models::AuthorizationForm) ? x : ::Io::Flow::V0::Models::AuthorizationForm.from_json(x)) r = @client.request("/#{CGI.escape(organization)}/authorizations/#{CGI.escape(key)}").with_query(query).with_json(.to_json).put ::Io::Flow::V0::Models::Authorization.from_json(r) end |
#put_value_by_key(organization, key, authorization_value_form, incoming = {}) ⇒ Object
Updates the value of the authorization, or returns the authorization as-is if the value is the same.
2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 2912 def put_value_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 = { :expand => (x = opts.delete(:expand); x.nil? ? nil : HttpClient::Preconditions.assert_class('expand', x, Array).map { |v| HttpClient::Preconditions.assert_class('expand', v, String) }) }.delete_if { |k, v| v.nil? } (x = ; x.is_a?(::Io::Flow::V0::Models::AuthorizationValueForm) ? x : ::Io::Flow::V0::Models::AuthorizationValueForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/authorizations/#{CGI.escape(key)}/value").with_query(query).with_json(.to_json).put ::Io::Flow::V0::Models::Authorization.from_json(r) end |