Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31f9019
commit 168d742
Showing
33 changed files
with
892 additions
and
138 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
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
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,69 @@ | ||
module Braintree | ||
class AdvancedSearch | ||
class SearchNode | ||
def self.operators(*operator_names) | ||
operator_names.each do |operator| | ||
define_method(operator) do |value| | ||
@parent.add_criteria(@node_name, operator => value.to_s) | ||
end | ||
end | ||
end | ||
|
||
def initialize(name, parent) | ||
@node_name, @parent = name, parent | ||
end | ||
end | ||
|
||
class TextNode < SearchNode | ||
operators :is, :is_not, :ends_with, :starts_with, :contains | ||
end | ||
|
||
class MultipleValueNode < SearchNode | ||
def in(*values) | ||
values.flatten! | ||
|
||
unless allowed_values.nil? | ||
bad_values = values - allowed_values | ||
raise ArgumentError.new("Invalid argument(s) for #{@node_name}: #{bad_values.join(", ")}") if bad_values.any? | ||
end | ||
|
||
@parent.add_criteria(@node_name, values) | ||
end | ||
|
||
def initialize(name, parent, options) | ||
super(name, parent) | ||
@options = options | ||
end | ||
|
||
def allowed_values | ||
@options[:allows] | ||
end | ||
end | ||
|
||
def self.search_fields(*fields) | ||
fields.each do |field| | ||
define_method(field) do | ||
TextNode.new(field, self) | ||
end | ||
end | ||
end | ||
|
||
def self.multiple_value_field(field, options={}) | ||
define_method(field) do | ||
MultipleValueNode.new(field, self, options) | ||
end | ||
end | ||
|
||
def initialize | ||
@criteria = {} | ||
end | ||
|
||
def add_criteria(key, value) | ||
@criteria[key] = value | ||
end | ||
|
||
def to_hash | ||
@criteria | ||
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
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,10 @@ | ||
module Braintree | ||
class SubscriptionSearch < AdvancedSearch | ||
search_fields :plan_id, :days_past_due | ||
multiple_value_field :status, :allows => [ | ||
Subscription::Status::Active, | ||
Subscription::Status::Canceled, | ||
Subscription::Status::PastDue | ||
] | ||
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
1 change: 1 addition & 0 deletions
1
lib/ssl/valicert_ca.crt → lib/ssl/sandbox_braintreegateway_com.ca.crt
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.