-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from arktseytlin/master
Committing ARBGetSubscriptionListRequest changes to Ruby SDK
- Loading branch information
Showing
10 changed files
with
301 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module AuthorizeNet::ARB | ||
module Fields | ||
EntityDescription = Struct.new(:node_structure, :entity_class, :arg_mapping) | ||
|
||
SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION = EntityDescription.new( | ||
[ | ||
{:id => :id}, | ||
{:name => :name}, | ||
{:status => :status}, | ||
{:createTimeStampUTC => :create_time_stamp_utc}, | ||
{:firstName => :first_name}, | ||
{:lastName => :last_name}, | ||
{:totalOccurrences => :total_occurrences}, | ||
{:pastOccurrences => :past_occurrences}, | ||
{:paymentMethod => :payment_method}, | ||
{:accountNumber => :account_number}, | ||
{:invoice => :invoice}, | ||
{:amount => :amount}, | ||
{:currencyId => :currency_id} | ||
], | ||
AuthorizeNet::ARB::SubscriptionDetail | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module AuthorizeNet::ARB | ||
|
||
class Paging | ||
|
||
# Models Paging | ||
include AuthorizeNet::Model | ||
|
||
attr_accessor :offset,:limit | ||
|
||
# Initializes Paging object. | ||
# | ||
# Typical usage: | ||
# paging = AuthorizeNet::ARB::Paging.new(1,1000) | ||
# | ||
# Valid values for offset: 1 to 100000 | ||
# Valid values for limit: 1 to 1000 | ||
# | ||
def initialize(offset,limit) | ||
@offset = offset | ||
@limit = limit | ||
end | ||
|
||
def to_hash | ||
hash = { | ||
:offset => @offset, | ||
:limit => @limit | ||
} | ||
hash.delete_if {|k, v| v.nil?} | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module AuthorizeNet::ARB | ||
|
||
class Sorting | ||
|
||
# Models Sorting | ||
include AuthorizeNet::Model | ||
|
||
attr_accessor :order_by, :order_descending | ||
|
||
# Initializes Sorting object. | ||
# | ||
# Typical usage: | ||
# sorting = AuthorizeNet::ARB::Sorting.new('name',true) | ||
# | ||
# Valid values for order_by values of the AuthorizeNet::ARB::Sorting: | ||
# id | ||
# name | ||
# status | ||
# createTimeStampUTC | ||
# lastName | ||
# firstName | ||
# accountNumber | ||
# amount | ||
# pastOccurrences | ||
# | ||
# Valid values for order_descending: true, false, 1, 0 | ||
# | ||
def initialize(order_by, order_descending) | ||
@order_by = order_by | ||
@order_descending = order_descending | ||
end | ||
|
||
def to_hash | ||
hash = { | ||
:order_by => @order_by, | ||
:order_descending => @order_descending | ||
} | ||
hash.delete_if {|k, v| v.nil?} | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module AuthorizeNet::ARB | ||
|
||
# Models Subscription Detail. | ||
class SubscriptionDetail | ||
|
||
include AuthorizeNet::Model | ||
|
||
attr_accessor :id, :name, :status, :create_time_stamp_utc, :first_name, | ||
:last_name, :total_occurrences, :past_occurrences, | ||
:payment_method, :account_number, :invoice, :amount, :currency_id | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module AuthorizeNet::ARB | ||
|
||
class SubscriptionListResponse < AuthorizeNet::XmlResponse | ||
# Constructs a new response object from a +raw_response. You don't typically | ||
# construct this object yourself, as AuthorizeNet::ARB::Transaction will | ||
# build one for you when it makes the request to the gateway. | ||
def initialize(raw_response, transaction) | ||
super | ||
unless connection_failure? | ||
begin | ||
@subscription_details = @root.at_css('subscriptionDetails') | ||
@subscription_detail = @root.at_css('subscriptionDetail') | ||
@total_num_in_resultset = node_content_unless_nil(@root.at_css('totalNumInResultSet')) | ||
|
||
rescue | ||
@raw_response = $! | ||
end | ||
end | ||
end | ||
|
||
# Returns total number of subscriptions matching the search criteria | ||
def total_num_in_resultset | ||
@total_num_in_resultset | ||
end | ||
|
||
# Returns an Array of SubscriptionDetail objects built from the entities returned in the response. Returns nil if no subscriptions were returned. | ||
def subscription_details | ||
unless @subscription_details.nil? | ||
subscription_details = [] | ||
@subscription_details.element_children.each do |child| | ||
unless child.nil? | ||
subscription_detail = build_entity(child, Fields::SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION) | ||
|
||
subscription_details <<= subscription_detail | ||
end | ||
end | ||
return subscription_details unless subscription_details.length == 0 | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.