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_details_by_key(organization, key, value) ⇒ Object
Accepts the data from the underlying processor to, for example, record the 3DSecure results.
-
#put_by_key(organization, key, authorization_form, incoming = {}) ⇒ Object
Attempts to create an authorization identified by the provided key.
Constructor Details
#initialize(client) ⇒ Authorizations
Returns a new instance of Authorizations.
3148 3149 3150 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3148 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.
3223 3224 3225 3226 3227 3228 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3223 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
3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3152 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.
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3196 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
3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3181 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.
3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3169 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_details_by_key(organization, key, value) ⇒ Object
Accepts the data from the underlying processor to, for example, record the 3DSecure results
3232 3233 3234 3235 3236 3237 3238 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3232 def post_details_by_key(organization, key, value) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) HttpClient::Preconditions.assert_class('value', value, BasicObject) r = @client.request("/#{CGI.escape(organization)}/authorizations/#{CGI.escape(key)}/details").with_body(value).post ::Io::Flow::V0::Models::Authorization.from_json(r) end |
#put_by_key(organization, key, authorization_form, incoming = {}) ⇒ Object
Attempts to create an authorization identified by the provided key. Multiple requests using the same key are idempotent.
3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3209 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 |