crowd_pay 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/crowd_pay.gemspec +3 -3
- data/lib/crowd_pay.rb +25 -22
- data/lib/crowd_pay/account.rb +21 -23
- data/lib/crowd_pay/asset.rb +4 -4
- data/lib/crowd_pay/escrow.rb +4 -1
- data/lib/crowd_pay/investor.rb +32 -25
- data/lib/crowd_pay/transaction.rb +6 -4
- data/lib/crowd_pay/verification.rb +7 -7
- data/lib/crowd_pay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 883c2b44d6fa8795f2cbb965b09f925cabed9c72
|
4
|
+
data.tar.gz: 20c376ad0ce104f95551819ccd972d81eb0ffa9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6005237150f079607b8056b7f584a4a64611e9f787b289a7c4aba6bb4c3a272f9adf91b1f7c7be409f6c80058fedc3093fc74524cb280b73641c01bb7ee8cd28
|
7
|
+
data.tar.gz: 02b28060c22a283604b75d1b2c96aeb1b3b268410a2a537736ac70230a0f4d14bce41aa1ea316c0c231ee7a2ee656c80552529df93f62f53af1ffeb92b1ff8fc
|
data/crowd_pay.gemspec
CHANGED
@@ -3,13 +3,13 @@ require File.expand_path('../lib/crowd_pay/version', __FILE__)
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'crowd_pay'
|
5
5
|
gem.version = CrowdPay::VERSION
|
6
|
-
gem.date = '
|
6
|
+
gem.date = Time.now.strftime '%Y-%m-%d'
|
7
7
|
gem.summary = 'A ruby client for the CrowdPay API using ActiveModel'
|
8
8
|
gem.description = 'A ruby client for CrowdPay\'s API using ActiveModel for easy to use ruby objects.' \
|
9
9
|
'This gem has been extracted from the Vested.org project courtesy of Calvert Foundation.'
|
10
10
|
gem.authors = ['Kelton Manzanares', 'Prakash Lingaiah', 'Krishnaprasad Varma']
|
11
11
|
gem.email = ['kelton.manzanares@gmail.com', 'plingaiah@qwinix.io', 'kvarma@qwinix.io']
|
12
|
-
gem.files = `git ls-files`.split(
|
12
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
13
13
|
gem.homepage = 'https://github.com/qwinix/crowd_pay'
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.add_runtime_dependency 'faraday', '~> 0.9'
|
18
18
|
|
19
19
|
gem.add_development_dependency 'rspec', '~> 2.14.1'
|
20
|
-
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_development_dependency 'rake', '~> 10.4.2'
|
21
21
|
gem.add_development_dependency 'factory_girl', '~> 4.2.0'
|
22
22
|
gem.add_development_dependency 'webmock', '~> 1.24.2'
|
23
23
|
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.5.0'
|
data/lib/crowd_pay.rb
CHANGED
@@ -12,12 +12,12 @@ module CrowdPay
|
|
12
12
|
autoload :Verification, 'crowd_pay/verification'
|
13
13
|
|
14
14
|
module InstanceMethods
|
15
|
-
def initialize(opts={})
|
15
|
+
def initialize(opts = {})
|
16
16
|
opts.each do |k, v|
|
17
17
|
associations = self.class.class_variable_get(:@@associations)
|
18
18
|
assoc_name = k.downcase.to_sym
|
19
19
|
|
20
|
-
if associations.
|
20
|
+
if associations.key?(assoc_name)
|
21
21
|
klass = associations[assoc_name][:class_name].constantize
|
22
22
|
|
23
23
|
association = v.each_with_object([]) do |data, array|
|
@@ -34,17 +34,17 @@ module CrowdPay
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def assign_attributes(hash)
|
37
|
-
|
37
|
+
send :initialize, hash
|
38
38
|
end
|
39
39
|
|
40
|
-
def populate_errors
|
41
|
-
|
42
|
-
if error.
|
43
|
-
model_state = error[
|
40
|
+
def populate_errors(error)
|
41
|
+
errors.add(:api, (error.key?('Message') ? error['Message'] : error))
|
42
|
+
if error.key?('ModelState')
|
43
|
+
model_state = error['ModelState'].symbolize_keys!
|
44
44
|
model_state.each do |k, v|
|
45
45
|
next if k == self.class.name.downcase.to_sym
|
46
46
|
v.each do |e|
|
47
|
-
|
47
|
+
errors.add(k.to_s.split('.').last, e)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -53,13 +53,13 @@ module CrowdPay
|
|
53
53
|
|
54
54
|
module ClassMethods
|
55
55
|
def create_connection
|
56
|
-
@@connection = Faraday.new(:
|
57
|
-
# faraday.response :logger if Rails.env.develop? || Rails.env.test? # log requests to STDOUT
|
56
|
+
@@connection = Faraday.new(url: domain) do |faraday|
|
58
57
|
faraday.adapter Faraday.default_adapter
|
59
58
|
|
60
59
|
faraday.headers['X-ApiKey'] = api_key
|
61
60
|
faraday.headers['X-PortalKey'] = portal_key
|
62
61
|
faraday.headers['X-ByPassValidation'] = by_pass_validation if by_pass_validation
|
62
|
+
faraday.headers['Authorization'] = authorization if authorization
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -75,23 +75,24 @@ module CrowdPay
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def build_object
|
79
|
-
obj =
|
78
|
+
def build_object(status, attributes)
|
79
|
+
obj = new
|
80
|
+
|
80
81
|
case status
|
81
82
|
when 200, 201
|
82
83
|
build_hash_object obj, attributes
|
83
84
|
when 409
|
84
85
|
build_hash_object obj, attributes['ModelObject']
|
85
86
|
when 400, 405, 404
|
86
|
-
#FIX ME: 404 catching is not tested
|
87
87
|
obj.populate_errors attributes
|
88
88
|
else
|
89
|
-
|
89
|
+
obj.errors.add(:base, "Unknown Error Status #{status}: crowd_pay.rb#parse method")
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
|
+
obj
|
92
93
|
end
|
93
94
|
|
94
|
-
def build_hash_object
|
95
|
+
def build_hash_object(obj, attributes)
|
95
96
|
attributes = attributes.each_with_object({}) do |(k, v), hash|
|
96
97
|
hash[k.downcase] = v
|
97
98
|
end
|
@@ -105,8 +106,8 @@ module CrowdPay
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
|
-
def post(url, data, cip_by_pass_validation=false)
|
109
|
-
data = data.to_json unless data.
|
109
|
+
def post(url, data, cip_by_pass_validation = false)
|
110
|
+
data = data.to_json unless data.is_a? String
|
110
111
|
|
111
112
|
connection.post do |req|
|
112
113
|
req.url(url)
|
@@ -117,7 +118,7 @@ module CrowdPay
|
|
117
118
|
end
|
118
119
|
|
119
120
|
def put(url, data)
|
120
|
-
data = data.to_json unless data.
|
121
|
+
data = data.to_json unless data.is_a? String
|
121
122
|
|
122
123
|
connection.put do |req|
|
123
124
|
req.url(url)
|
@@ -137,7 +138,7 @@ module CrowdPay
|
|
137
138
|
|
138
139
|
def register_association(assoc_name, details)
|
139
140
|
hash = class_variable_get(:@@associations)
|
140
|
-
class_variable_set(:@@associations, hash.merge({assoc_name => details.symbolize_keys}.symbolize_keys))
|
141
|
+
class_variable_set(:@@associations, hash.merge({ assoc_name => details.symbolize_keys }.symbolize_keys))
|
141
142
|
attr_accessor assoc_name.to_sym
|
142
143
|
end
|
143
144
|
end
|
@@ -146,15 +147,17 @@ module CrowdPay
|
|
146
147
|
base.send :include, InstanceMethods
|
147
148
|
base.extend ClassMethods
|
148
149
|
base.class_eval do
|
149
|
-
cattr_reader :domain, :api_key, :portal_key, :connection, :associations,
|
150
|
+
cattr_reader :domain, :api_key, :portal_key, :connection, :associations,
|
151
|
+
:by_pass_validation, :authorization
|
150
152
|
|
151
153
|
class_variable_set :@@domain, ENV['CROWD_PAY_DOMAIN']
|
152
154
|
class_variable_set :@@api_key, ENV['CROWD_PAY_API_KEY']
|
153
155
|
class_variable_set :@@portal_key, ENV['CROWD_PAY_PORTAL_KEY']
|
154
156
|
class_variable_set :@@by_pass_validation, ENV['CROWD_PAY_BY_PASS']
|
157
|
+
class_variable_set :@@authorization, ENV['CROWD_PAY_AUTH']
|
155
158
|
class_variable_set :@@associations, {}
|
156
159
|
|
157
|
-
unless
|
160
|
+
unless base.class_variable_get(:@@connection)
|
158
161
|
connection = base.create_connection
|
159
162
|
base.class_variable_set(:@@connection, connection)
|
160
163
|
end
|
data/lib/crowd_pay/account.rb
CHANGED
@@ -15,10 +15,8 @@ module CrowdPay
|
|
15
15
|
:contact_email, :idology_id, :available_balance,
|
16
16
|
:current_balance, :created_by_ip_address
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
register_association :assets, class_name: "CrowdPay::Asset"
|
21
|
-
register_association :transactions, class_name: "CrowdPay::Transaction"
|
18
|
+
register_association :assets, class_name: 'CrowdPay::Asset'
|
19
|
+
register_association :transactions, class_name: 'CrowdPay::Transaction'
|
22
20
|
|
23
21
|
validates_presence_of :investor_id
|
24
22
|
validates_presence_of :status_id
|
@@ -31,24 +29,24 @@ module CrowdPay
|
|
31
29
|
validates_presence_of :draft_account_name
|
32
30
|
validates_presence_of :created_by_ip_address
|
33
31
|
validates_presence_of :w9_code_id
|
34
|
-
validates_length_of :portal_account_number, :
|
35
|
-
validates_length_of :name_1, :
|
36
|
-
validates_length_of :name_2, :
|
37
|
-
validates_length_of :name_3, :
|
38
|
-
validates_length_of :name_4, :
|
39
|
-
validates_length_of :mailing_address_1, :
|
40
|
-
validates_length_of :mailing_address_2, :
|
41
|
-
validates_length_of :mailing_city, :
|
42
|
-
validates_length_of :mailing_state, :
|
43
|
-
validates_length_of :mailing_zip, :
|
44
|
-
validates_length_of :mailing_country, :
|
45
|
-
validates_length_of :draft_routing_number, :
|
46
|
-
validates_length_of :draft_account_number, :
|
47
|
-
validates_length_of :draft_account_name, :
|
48
|
-
validates_length_of :contact_name, :
|
49
|
-
validates_length_of :contact_phone, :
|
50
|
-
validates_length_of :contact_email, :
|
51
|
-
validates_length_of :created_by_ip_address, :
|
32
|
+
validates_length_of :portal_account_number, maximum: 30
|
33
|
+
validates_length_of :name_1, maximum: 50
|
34
|
+
validates_length_of :name_2, maximum: 50
|
35
|
+
validates_length_of :name_3, maximum: 50
|
36
|
+
validates_length_of :name_4, maximum: 50
|
37
|
+
validates_length_of :mailing_address_1, maximum: 40
|
38
|
+
validates_length_of :mailing_address_2, maximum: 40
|
39
|
+
validates_length_of :mailing_city, maximum: 40
|
40
|
+
validates_length_of :mailing_state, maximum: 30
|
41
|
+
validates_length_of :mailing_zip, maximum: 9
|
42
|
+
validates_length_of :mailing_country, maximum: 40
|
43
|
+
validates_length_of :draft_routing_number, maximum: 9
|
44
|
+
validates_length_of :draft_account_number, maximum: 17
|
45
|
+
validates_length_of :draft_account_name, maximum: 50
|
46
|
+
validates_length_of :contact_name, maximum: 75
|
47
|
+
validates_length_of :contact_phone, maximum: 20
|
48
|
+
validates_length_of :contact_email, maximum: 50
|
49
|
+
validates_length_of :created_by_ip_address, maximum: 25
|
52
50
|
|
53
51
|
def self.find(id)
|
54
52
|
url = "Crowdfunding/api/Account/#{id}"
|
@@ -63,7 +61,7 @@ module CrowdPay
|
|
63
61
|
end
|
64
62
|
|
65
63
|
def self.create(data)
|
66
|
-
url =
|
64
|
+
url = 'Crowdfunding/api/Account'
|
67
65
|
response = post(url, data)
|
68
66
|
parse(response)
|
69
67
|
end
|
data/lib/crowd_pay/asset.rb
CHANGED
@@ -4,12 +4,12 @@ module CrowdPay
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
include CrowdPay
|
6
6
|
|
7
|
-
register_association :transactions, class_name:
|
7
|
+
register_association :transactions, class_name: 'CrowdPay::Transaction'
|
8
8
|
|
9
9
|
attr_accessor :term, :effective_date, :interest_type, :interest_frequency,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
:interest_rate, :maturity_date, :third_party_asset_number,
|
11
|
+
:quantity, :cusip_number, :id, :description, :number,
|
12
|
+
:sold_date, :market_value, :cost_basis, :created_by_ip_address
|
13
13
|
|
14
14
|
def self.find(account_id, id)
|
15
15
|
url = "Crowdfunding/api/Account/#{account_id}/Assets/#{id}"
|
data/lib/crowd_pay/escrow.rb
CHANGED
@@ -4,7 +4,10 @@ module CrowdPay
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
include CrowdPay
|
6
6
|
|
7
|
-
attr_accessor :id, :issue_number, :portal_issue_number, :offering_type,
|
7
|
+
attr_accessor :id, :issue_number, :portal_issue_number, :offering_type,
|
8
|
+
:minimum_investment_amount, :maximum_investment_amount,
|
9
|
+
:issue_amount, :cash_balance, :principal_balance, :date,
|
10
|
+
:description, :amount, :status, :transactions
|
8
11
|
|
9
12
|
def self.find(id=nil)
|
10
13
|
url = 'Crowdfunding/api/Escrows'
|
data/lib/crowd_pay/investor.rb
CHANGED
@@ -4,7 +4,14 @@ module CrowdPay
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
include CrowdPay
|
6
6
|
|
7
|
-
attr_accessor :id, :investor_key, :tax_id_number, :first_name, :middle_name,
|
7
|
+
attr_accessor :id, :investor_key, :tax_id_number, :first_name, :middle_name,
|
8
|
+
:last_name, :name, :birth_date, :mailing_address_1,
|
9
|
+
:mailing_address_2, :mailing_city, :mailing_state,
|
10
|
+
:mailing_zip, :mailing_country, :is_mailing_address_foreign,
|
11
|
+
:legal_address_1, :legal_address_2, :legal_city, :legal_state,
|
12
|
+
:legal_zip, :legal_country, :is_legal_address_foreign,
|
13
|
+
:primary_phone, :secondary_phone, :is_person, :email,
|
14
|
+
:is_cip_satisfied, :portal_investor_number, :created_by_ip_address
|
8
15
|
|
9
16
|
validates_presence_of :tax_id_number
|
10
17
|
validates_presence_of :is_mailing_address_foreign
|
@@ -12,29 +19,29 @@ module CrowdPay
|
|
12
19
|
validates_presence_of :is_cip_satisfied
|
13
20
|
validates_presence_of :created_by_ip_address
|
14
21
|
|
15
|
-
validates_length_of :tax_id_number, :
|
16
|
-
validates_length_of :tax_id_number, :
|
17
|
-
validates_length_of :first_name, :
|
18
|
-
validates_length_of :middle_name, :
|
19
|
-
validates_length_of :last_name, :
|
20
|
-
validates_length_of :name, :
|
21
|
-
validates_length_of :mailing_address_1, :
|
22
|
-
validates_length_of :mailing_address_2, :
|
23
|
-
validates_length_of :mailing_city, :
|
24
|
-
validates_length_of :mailing_state, :
|
25
|
-
validates_length_of :mailing_zip, :
|
26
|
-
validates_length_of :mailing_country, :
|
27
|
-
validates_length_of :legal_address_1, :
|
28
|
-
validates_length_of :legal_address_2, :
|
29
|
-
validates_length_of :legal_city, :
|
30
|
-
validates_length_of :legal_state, :
|
31
|
-
validates_length_of :legal_zip, :
|
32
|
-
validates_length_of :legal_country, :
|
33
|
-
validates_length_of :primary_phone, :
|
34
|
-
validates_length_of :secondary_phone, :
|
35
|
-
validates_length_of :email, :
|
36
|
-
validates_length_of :portal_investor_number, :
|
37
|
-
validates_length_of :created_by_ip_address, :
|
22
|
+
validates_length_of :tax_id_number, maximum: 9
|
23
|
+
validates_length_of :tax_id_number, minimum: 9
|
24
|
+
validates_length_of :first_name, maximum: 50
|
25
|
+
validates_length_of :middle_name, maximum: 50
|
26
|
+
validates_length_of :last_name, maximum: 50
|
27
|
+
validates_length_of :name, maximum: 150
|
28
|
+
validates_length_of :mailing_address_1, maximum: 40
|
29
|
+
validates_length_of :mailing_address_2, maximum: 40
|
30
|
+
validates_length_of :mailing_city, maximum: 40
|
31
|
+
validates_length_of :mailing_state, maximum: 30
|
32
|
+
validates_length_of :mailing_zip, maximum: 9
|
33
|
+
validates_length_of :mailing_country, maximum: 40
|
34
|
+
validates_length_of :legal_address_1, maximum: 40
|
35
|
+
validates_length_of :legal_address_2, maximum: 40
|
36
|
+
validates_length_of :legal_city, maximum: 40
|
37
|
+
validates_length_of :legal_state, maximum: 30
|
38
|
+
validates_length_of :legal_zip, maximum: 9
|
39
|
+
validates_length_of :legal_country, maximum: 40
|
40
|
+
validates_length_of :primary_phone, maximum: 10
|
41
|
+
validates_length_of :secondary_phone, maximum: 10
|
42
|
+
validates_length_of :email, maximum: 50
|
43
|
+
validates_length_of :portal_investor_number, maximum: 30
|
44
|
+
validates_length_of :created_by_ip_address, maximum: 25
|
38
45
|
|
39
46
|
def self.find(id)
|
40
47
|
url = "Crowdfunding/api/Investor/#{id}"
|
@@ -43,7 +50,7 @@ module CrowdPay
|
|
43
50
|
end
|
44
51
|
|
45
52
|
def self.create(data)
|
46
|
-
url =
|
53
|
+
url = 'Crowdfunding/api/Investor'
|
47
54
|
response = post(url, data)
|
48
55
|
parse(response)
|
49
56
|
end
|
@@ -4,14 +4,16 @@ module CrowdPay
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
include CrowdPay
|
6
6
|
|
7
|
-
attr_accessor :id, :account_id, :asset_id, :date, :reference, :description,
|
7
|
+
attr_accessor :id, :account_id, :asset_id, :date, :reference, :description,
|
8
|
+
:amount, :status, :effective_date, :maturity_date, :cusip_number,
|
9
|
+
:created_by_ip_address
|
8
10
|
|
9
11
|
validates_presence_of :account_id
|
10
12
|
validates_presence_of :amount
|
11
13
|
validates_presence_of :created_by_ip_address
|
12
|
-
validates_length_of :reference, :
|
13
|
-
validates_length_of :description, :
|
14
|
-
validates_length_of :created_by_ip_address, :
|
14
|
+
validates_length_of :reference, maximum: 20
|
15
|
+
validates_length_of :description, maximum: 50
|
16
|
+
validates_length_of :created_by_ip_address, maximum: 25
|
15
17
|
|
16
18
|
def self.find(account_id, id)
|
17
19
|
url = "Crowdfunding/api/Account/#{account_id}/Transaction/#{id}"
|
@@ -5,12 +5,12 @@ module CrowdPay
|
|
5
5
|
include CrowdPay
|
6
6
|
|
7
7
|
attr_accessor :id, :firstName, :lastName, :address, :city, :state, :zip,
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
:taxpayerId, :birthMonth, :birthDay, :birthYear, :created_by_ip_address,
|
9
|
+
:message, :key, :questions, :response_body, :request_data, :summary,
|
10
|
+
:qualifiers
|
11
11
|
|
12
12
|
def self.verify(data, bypass_validation)
|
13
|
-
url =
|
13
|
+
url = 'identification/api/v1/ops/verify-identity'
|
14
14
|
response = post(url, data, bypass_validation)
|
15
15
|
obj = parse(response)
|
16
16
|
obj.response_body = response.body
|
@@ -19,7 +19,7 @@ module CrowdPay
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.verify_answers(data)
|
22
|
-
url =
|
22
|
+
url = 'identification/api/v1/ops/verify-answers'
|
23
23
|
response = post(url, data)
|
24
24
|
obj = parse(response)
|
25
25
|
obj.response_body = response.body
|
@@ -28,7 +28,7 @@ module CrowdPay
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def pass?
|
31
|
-
|
31
|
+
message.downcase == 'pass' || summary.try(:downcase) == 'pass'
|
32
32
|
end
|
33
33
|
|
34
34
|
def fail?
|
@@ -36,7 +36,7 @@ module CrowdPay
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def soft_fail?
|
39
|
-
!
|
39
|
+
!questions.nil?
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/crowd_pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowd_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelton Manzanares
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|