Class: BigDoor::NamedTransactionGroup
- Inherits:
-
ResourceWithAssociation
- Object
- OpenStruct
- Resource
- ResourceWithAssociation
- BigDoor::NamedTransactionGroup
- Defined in:
- lib/big_door/named_transaction_group.rb
Overview
This module provides NamedTransactionGroup Resource object corresponding to /named_transaction_group BigDoor API end point
Instance Method Summary collapse
-
#associate_with(transaction, client, primary = 1) ⇒ Object
Assocaiate this NamedTransactionGroup with NamedTransaction.
-
#execute(end_user_login, payload, client) ⇒ Object
Executes this NamedTransaction.
-
#initialize(hash = {}) ⇒ NamedTransactionGroup
constructor
Initialize new NamedTransaction object with optional Hash.
Methods inherited from Resource
all, #delete, #end_point, end_point, end_point_from_classname, #get_id, #instance_to_payload, #load, #response_to_instance, #save
Constructor Details
#initialize(hash = {}) ⇒ NamedTransactionGroup
Initialize new NamedTransaction object with optional Hash
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/big_door/named_transaction_group.rb', line 13 def initialize( hash = {} ) $log.debug( "NamedTransactionGroup init with hash = #{hash.inspect}") default_values = { 'end_user_cap' => 0, 'end_user_cap_interval' => 0, } default_values.merge!( hash ) $log.debug( "NamedTransactionGroup default_values = #{default_values.inspect}") super( default_values ) end |
Instance Method Details
#associate_with(transaction, client, primary = 1) ⇒ Object
Assocaiate this NamedTransactionGroup with NamedTransaction
@param [BigDoor::NamedTransaction] transaction
NamedTransaction to be associated with
@param [BigDoor::Client] client
Initialized BigDoor::Client object
@param [Fixnum] primary
Indicates whether assocatiate NamedTransaction is primary in this
Named Transaction Group
@return [Hash] Decoded JSON response if any
71 72 73 |
# File 'lib/big_door/named_transaction_group.rb', line 71 def associate_with( transaction, client, primary = 1) super( transaction, client, {'named_transaction_is_primary' => primary } ) end |
#execute(end_user_login, payload, client) ⇒ Object
Executes this NamedTransaction
@param [String] end_user_login
String representing end_use_login
@param [Hash] payload
Hash to be converted to HTTP POST form-url-encoded body
@param [BigDoor::Client] client
Initialized BigDoor::Client object
@return [Hash] Decoded JSON response if any
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/big_door/named_transaction_group.rb', line 38 def execute( end_user_login, payload, client ) $log.debug('execute transaction'); # FIXME check for self.resource_id defined # FIXME check end_user_login uri = sprintf '%s/%s/execute/%s', end_point, self.resource_id, end_user_login $log.debug( sprintf 'uri = %s', uri ) payload ||= { 'verbosity' => '6' } payload['verbosity'] = 9 unless payload['verbosity'] result = client.post( uri , { 'format' => 'json'}, payload ) $log.debug(sprintf 'result = %s', result.inspect ); result end |