crowd_pay 0.0.1

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.
@@ -0,0 +1,26 @@
1
+ module CrowdPay
2
+ class Asset
3
+ include ActiveModel::AttributeMethods
4
+ include ActiveModel::Validations
5
+ include CrowdPay
6
+
7
+ register_association :transactions, class_name: "CrowdPay::Transaction"
8
+
9
+ attr_accessor :term, :effective_date, :interest_type, :interest_frequency,
10
+ :interest_rate, :maturity_date, :third_party_asset_number, :quantity,
11
+ :cusip_number, :id, :description, :number, :sold_date, :market_value,
12
+ :cost_basis, :created_by_ip_address
13
+
14
+ def self.find(account_id, id)
15
+ url = "Crowdfunding/api/Account/#{account_id}/Assets/#{id}"
16
+ response = get(url)
17
+ parse(response)
18
+ end
19
+
20
+ def self.find_with_transactions(account_id, id)
21
+ url = "Crowdfunding/api/Account/#{account_id}/Assets/#{id}/Transactions"
22
+ response = get(url)
23
+ parse(response)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module CrowdPay
2
+ class Escrow
3
+ include ActiveModel::AttributeMethods
4
+ include ActiveModel::Validations
5
+ include CrowdPay
6
+
7
+ attr_accessor :id, :issue_number, :portal_issue_number, :offering_type, :minimum_investment_amount, :maximum_investment_amount, :issue_amount, :cash_balance, :principal_balance, :date, :description, :amount, :status, :transactions
8
+
9
+ def self.find(id=nil)
10
+ url = 'Crowdfunding/api/Escrows'
11
+ url += "/#{id}" if id
12
+ response = get(url)
13
+ parse(response)
14
+ end
15
+
16
+ def self.find_with_transactions(id)
17
+ url = "Crowdfunding/api/Escrows/#{id}/Transactions"
18
+ response = get(url)
19
+ parse(response)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ module CrowdPay
2
+ class Investor
3
+ include ActiveModel::AttributeMethods
4
+ include ActiveModel::Validations
5
+ include CrowdPay
6
+
7
+ attr_accessor :id, :investor_key, :tax_id_number, :first_name, :middle_name, :last_name, :name, :birth_date, :mailing_address_1, :mailing_address_2, :mailing_city, :mailing_state, :mailing_zip, :mailing_country, :is_mailing_address_foreign, :legal_address_1, :legal_address_2, :legal_city, :legal_state, :legal_zip, :legal_country, :is_legal_address_foreign, :primary_phone, :secondary_phone, :is_person, :email, :is_cip_satisfied, :portal_investor_number, :created_by_ip_address
8
+
9
+ validates_presence_of :tax_id_number
10
+ validates_presence_of :is_mailing_address_foreign
11
+ validates_presence_of :is_person
12
+ validates_presence_of :is_cip_satisfied
13
+ validates_presence_of :created_by_ip_address
14
+
15
+ validates_length_of :tax_id_number, :maximum => 9
16
+ validates_length_of :tax_id_number, :minimum => 9
17
+ validates_length_of :first_name, :maximum => 50
18
+ validates_length_of :middle_name, :maximum => 50
19
+ validates_length_of :last_name, :maximum => 50
20
+ validates_length_of :name, :maximum => 150
21
+ validates_length_of :mailing_address_1, :maximum => 40
22
+ validates_length_of :mailing_address_2, :maximum => 40
23
+ validates_length_of :mailing_city, :maximum => 40
24
+ validates_length_of :mailing_state, :maximum => 30
25
+ validates_length_of :mailing_zip, :maximum => 9
26
+ validates_length_of :mailing_country, :maximum => 40
27
+ validates_length_of :legal_address_1, :maximum => 40
28
+ validates_length_of :legal_address_2, :maximum => 40
29
+ validates_length_of :legal_city, :maximum => 40
30
+ validates_length_of :legal_state, :maximum => 30
31
+ validates_length_of :legal_zip, :maximum => 9
32
+ validates_length_of :legal_country, :maximum => 40
33
+ validates_length_of :primary_phone, :maximum => 10
34
+ validates_length_of :secondary_phone, :maximum => 10
35
+ validates_length_of :email, :maximum => 50
36
+ validates_length_of :portal_investor_number, :maximum => 30
37
+ validates_length_of :created_by_ip_address, :maximum => 25
38
+
39
+ def self.find(id)
40
+ url = "Crowdfunding/api/Investor/#{id}"
41
+ response = get(url)
42
+ parse(response)
43
+ end
44
+
45
+ def self.create(data)
46
+ url = "Crowdfunding/api/Investor"
47
+ response = post(url, data)
48
+ parse(response)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ module CrowdPay
2
+ class Transaction
3
+ include ActiveModel::AttributeMethods
4
+ include ActiveModel::Validations
5
+ include CrowdPay
6
+
7
+ attr_accessor :id, :account_id, :asset_id, :date, :reference, :description, :amount, :status, :effective_date, :maturity_date, :cusip_number, :created_by_ip_address
8
+
9
+ validates_presence_of :account_id
10
+ validates_presence_of :amount
11
+ validates_presence_of :created_by_ip_address
12
+ validates_length_of :reference, :maximum => 20
13
+ validates_length_of :description, :maximum => 50
14
+ validates_length_of :created_by_ip_address, :maximum => 25
15
+
16
+ def self.find(account_id, id)
17
+ url = "Crowdfunding/api/Account/#{account_id}/Transaction/#{id}"
18
+ response = get(url)
19
+ parse(response)
20
+ end
21
+
22
+ def self.withdraw_funds(data)
23
+ url = "Crowdfunding/api/Account/#{data[:account_id]}/Transaction/WithdrawFunds"
24
+ response = post(url, data)
25
+ parse(response)
26
+ end
27
+
28
+ def self.fund_debt_escrow(data)
29
+ url = "Crowdfunding/api/Account/#{data[:account_id]}/Transaction/FundDebtEscrow"
30
+ response = post(url, data)
31
+ parse(response)
32
+ end
33
+
34
+ def self.fund_account(data)
35
+ url = "Crowdfunding/api/Account/#{data[:account_id]}/Transaction/FundAccount"
36
+ response = post(url, data)
37
+ parse(response)
38
+ end
39
+
40
+ def self.debt_pay(data)
41
+ url = "Crowdfunding/api/Account/#{data[:account_id]}/Transaction/DebtPay"
42
+ response = post(url, data)
43
+ parse(response)
44
+ end
45
+
46
+ def self.reinvest_debt(data)
47
+ url = "Crowdfunding/api/Account/#{data[:account_id]}/Transaction/ReinvestDebt"
48
+ response = post(url, data)
49
+ parse(response)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+ module CrowdPay
2
+ class Verification
3
+ include ActiveModel::AttributeMethods
4
+ include ActiveModel::Validations
5
+ include CrowdPay
6
+
7
+ attr_accessor :id, :firstName, :lastName, :address, :city, :state, :zip,
8
+ :taxpayerId, :birthMonth, :birthDay, :birthYear, :created_by_ip_address,
9
+ :message, :key, :questions, :response_body, :request_data, :summary,
10
+ :qualifiers
11
+
12
+ def self.verify(data, bypass_validation)
13
+ url = "identification/api/v1/ops/verify-identity"
14
+ response = post(url, data, bypass_validation)
15
+ obj = parse(response)
16
+ obj.response_body = response.body
17
+ obj.request_data = data.to_s
18
+ obj
19
+ end
20
+
21
+ def self.verify_answers(data)
22
+ url = "identification/api/v1/ops/verify-answers"
23
+ response = post(url, data)
24
+ obj = parse(response)
25
+ obj.response_body = response.body
26
+ obj.request_data = data.to_s
27
+ obj
28
+ end
29
+
30
+ def pass?
31
+ self.message.downcase == 'pass' || self.summary.try(:downcase) == 'pass'
32
+ end
33
+
34
+ def fail?
35
+ !pass?
36
+ end
37
+
38
+ def soft_fail?
39
+ !self.questions.nil?
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module CrowdPay
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,287 @@
1
+ require "spec_helper"
2
+
3
+ describe CrowdPay::Account do
4
+
5
+ let(:account) { FactoryGirl.build(:account) }
6
+
7
+ context "validate factories" do
8
+ it "should validate the account factories" do
9
+ expect(account).to be_valid
10
+ end
11
+ end
12
+
13
+ context "Validations" do
14
+
15
+ it "investor_id presence" do
16
+ account.investor_id = nil
17
+ expect(account).to be_invalid
18
+ end
19
+
20
+ it "is_mailing_address_foreign presence" do
21
+ account.is_mailing_address_foreign = nil
22
+ expect(account).to be_invalid
23
+ end
24
+
25
+ it "is_cip_satisfied presence" do
26
+ account.is_cip_satisfied = nil
27
+ expect(account).to be_invalid
28
+ end
29
+
30
+
31
+ it "status_id presence" do
32
+ account.status_id = nil
33
+ expect(account).to be_invalid
34
+ end
35
+
36
+ it "account_type_id presence" do
37
+ account.account_type_id = nil
38
+ expect(account).to be_invalid
39
+ end
40
+
41
+ it "draft_account_type_id presence" do
42
+ account.draft_account_type_id = nil
43
+ expect(account).to be_invalid
44
+ end
45
+
46
+ it "draft_routing_number presence" do
47
+ account.draft_routing_number = nil
48
+ expect(account).to be_invalid
49
+ end
50
+
51
+ it "draft_account_number presence" do
52
+ account.draft_account_number = nil
53
+ expect(account).to be_invalid
54
+ end
55
+
56
+ it "draft_account_name presence" do
57
+ account.draft_account_name = nil
58
+ expect(account).to be_invalid
59
+ end
60
+
61
+ it "created_by_ip_address presence" do
62
+ account.created_by_ip_address = nil
63
+ expect(account).to be_invalid
64
+ end
65
+
66
+ it "w9_code_id presence" do
67
+ account.w9_code_id = nil
68
+ expect(account).to be_invalid
69
+ end
70
+
71
+
72
+ it "maximum lenth of portal_account_number" do
73
+ account.portal_account_number = "32424324354544523674523645345345"
74
+ expect(account).to be_invalid
75
+ end
76
+
77
+ it "maximum lenth of name_1" do
78
+ account.name_1 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs"
79
+ expect(account).to be_invalid
80
+ end
81
+
82
+ it "maximum lenth of name_2" do
83
+ account.name_2 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs"
84
+ expect(account).to be_invalid
85
+ end
86
+
87
+ it "maximum lenth of name_3" do
88
+ account.name_3 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs"
89
+ expect(account).to be_invalid
90
+ end
91
+
92
+ it "maximum lenth of name_4" do
93
+ account.name_4 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs"
94
+ expect(account).to be_invalid
95
+ end
96
+
97
+ it "maximum lenth of mailing_address_1" do
98
+ account.mailing_address_1 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf"
99
+ expect(account).to be_invalid
100
+ end
101
+
102
+ it "maximum lenth of mailing_address_2" do
103
+ account.mailing_address_2 = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf"
104
+ expect(account).to be_invalid
105
+ end
106
+
107
+ it "maximum lenth of mailing_city" do
108
+ account.mailing_city = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf"
109
+ expect(account).to be_invalid
110
+ end
111
+
112
+ it "maximum lenth of mailing_state" do
113
+ account.mailing_state = "adsdsdsdsq dfdsfdsfds fdsfdfsdfq"
114
+ expect(account).to be_invalid
115
+ end
116
+
117
+ it "maximum lenth of mailing_zip" do
118
+ account.mailing_zip = "abthiendjk"
119
+ expect(account).to be_invalid
120
+ end
121
+
122
+ it "maximum lenth of mailing_country" do
123
+ account.mailing_country = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf"
124
+ expect(account).to be_invalid
125
+ end
126
+
127
+ it "maximum lenth of draft_account_type_id" do
128
+ account.draft_routing_number = "12345678911"
129
+ expect(account).to be_invalid
130
+ end
131
+
132
+ it "maximum lenth of draft_account_number" do
133
+ account.draft_account_number = "1234567890123456789"
134
+ expect(account).to be_invalid
135
+ end
136
+
137
+ it "maximum lenth of draft_account_name" do
138
+ account.draft_account_name = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs"
139
+ expect(account).to be_invalid
140
+ end
141
+
142
+ it "maximum lenth of contact_name" do
143
+ account.contact_name = "adsdsdsds dfdsfdsfds fdsfdfsdf fdsfdsfdsf fdsfsdfdfs fdsfsdfdfs fdsfsdfdfs fdsfsdfdfs fdsfsdfdfs"
144
+ expect(account).to be_invalid
145
+ end
146
+
147
+ it "maximum lenth of contact_phone" do
148
+ account.contact_phone = "123456789012345678911"
149
+ expect(account).to be_invalid
150
+ end
151
+
152
+ it "maximum lenth of contact_email" do
153
+ account.contact_email = "sadasdasdsavxcvcx@fdsfdsfdsfgdfgtreter.dsfdsfdsfdsfds"
154
+ expect(account).to be_invalid
155
+ end
156
+
157
+ it "maximum lenth of created_by_ip_address" do
158
+ account.created_by_ip_address = "123.4567.891.23456.789123456789"
159
+ expect(account).to be_invalid
160
+ end
161
+ end
162
+
163
+ context "create" do
164
+ context "positive case" do
165
+ it "should create a new account" do
166
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account"
167
+ account_attributes = FactoryGirl.attributes_for(:account)
168
+ stub_request(:post, url).to_return(:status => 201, :body => "{\"id\":82980,\"number\":\"$1000605486\",\"portal_account_number\":\"youraccountnumber\",\"investor_id\":78548,\"name_1\":\"InvestorFirst InvestorMiddle InvestorLast\",\"name_2\":null,\"name_3\":null,\"name_4\":null,\"mailing_address_1\":\"123 Ave A\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":true,\"available_balance\":0.00,\"current_balance\":0.00,\"is_cip_satisfied\":false,\"draft_account_type_id\":1,\"draft_routing_number\":\"*****0870\",\"draft_account_number\":\"******7890\",\"draft_account_name\":\"First Last\",\"status_id\":1,\"account_type_id\":12,\"w9_code_id\":1,\"contact_name\":\"InvestorFirst InvestorLast\",\"contact_phone\":\"8061234567\",\"contact_email\":\"fi+rst.l+ast@somewhere.com\",\"idology_id\":123456,\"created_by_ip_address\":\"192.168.2.126\",\"Assets\":[],\"Transactions\":[]}")
169
+ account = CrowdPay::Account.create(account_attributes)
170
+ expect(account).to be_an(CrowdPay::Account)
171
+ expect(account.assets).to eq([])
172
+ expect(account.transactions).to eq([])
173
+ end
174
+ end
175
+
176
+ context "negative case" do
177
+ it "should not create a new account" do
178
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account"
179
+ stub_request(:post, url).to_return(:status => 400, :body => "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"account\":[\"An error has occurred.\",\"An error has occurred.\",\"An error has occurred.\"],\"account.draft_account_type_id \":[\"The draft_account_type_id field is required.\"],\"account.draft_routing_number \":[\"The draft_routing_number field is required.\"],\" account.draft_account_number \":[\"The draft_account_number field is required.\"], \"account. draft_account_name \":[\"The draft_account_name field is required.\"], \"account. status_id \":[\"The field status_id must match the regular expression '[1-3]'.\"], \"account. account_type_id \":[\"The field account_type_id must match the regular expression '[2]|1[1-2]'.\"], \"account. created_by_ip_address \":[\"The created_by_ip_address field is required.\"]}}")
180
+ account = CrowdPay::Account.create({})
181
+ expect(account).to be_an(CrowdPay::Account)
182
+ # expect(account.errors["draft_account_type_id"]).to eq(["The draft_account_type_id field is required."])
183
+ # expect(account.errors["draft_routing_number"]).to eq(["The draft_routing_number field is required."])
184
+ # expect(account.errors["draft_account_number"]).to eq(["The draft_account_number field is required."])
185
+ # expect(account.errors["draft_account_name"]).to eq(["The draft_account_name field is required."])
186
+ # expect(account.errors["status_id"]).to eq(["The field status_id must match the regular expression '[1-3]'."])
187
+ # expect(account.errors["account_type_id"]).to eq(["The field account_type_id must match the regular expression '[2]|1[1-2]'."])
188
+ # expect(account.errors["created_by_ip_address"]).to eq(["The created_by_ip_address field is required."])
189
+ end
190
+ end
191
+ end
192
+
193
+ context "find" do
194
+ context "positive case" do
195
+ it "should get an account with id" do
196
+ account_id = "82980"
197
+ stub_request(:get, "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}").to_return(:status => 200, :body => "{\"id\":78627,\"investor_key\":\"a3cda761-78ff-4789-84fb-80a35628f95e\",\"tax_id_number\":\"*****8718\",\"first_name\":\"Investor First\",\"middle_name\":\"Investor Middle\",\"last_name\":\"Investor Last\",\"name\":\"Investor First Investor Middle Investor Last\",\"birth_date\":\"1985-04-07T00:00:00\",\"mailing_address_1\":\"123 Ave A\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":false,\"legal_address_1\":\"123 Ave A\",\"legal_address_2\":null,\"legal_city\":\"Somewhere\",\"legal_state\":\"TX\",\"legal_zip\":\"79109\",\"legal_country\":null,\"is_legal_address_foreign\":false,\"primary_phone\":\"1112223333\",\"secondary_phone\":\"2223334444\",\"is_person\":true,\"email\":\"cgrimes@qwinixtech.com\",\"is_cip_satisfied\":false,\"portal_investor_number\":\"yourinvestornumber\",\"created_by_ip_address\":\"192.168.2.61\",\"Assets\":[]}")
198
+ account = CrowdPay::Account.find(account_id)
199
+ expect(account).to be_an(CrowdPay::Account)
200
+ end
201
+
202
+ it "should get an account with id along with assets and transactions" do
203
+ account_id = "82980"
204
+ stub_request(:get, "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}").to_return(:status => 200, :body => "{\"id\":78627,\"investor_key\":\"a3cda761-78ff-4789-84fb-80a35628f95e\",\"tax_id_number\":\"*****8718\",\"first_name\":\"Investor First\",\"middle_name\":\"Investor Middle\",\"last_name\":\"Investor Last\",\"name\":\"Investor First Investor Middle Investor Last\",\"birth_date\":\"1985-04-07T00:00:00\",\"mailing_address_1\":\"123 Ave A\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":false,\"legal_address_1\":\"123 Ave A\",\"legal_address_2\":null,\"legal_city\":\"Somewhere\",\"legal_state\":\"TX\",\"legal_zip\":\"79109\",\"legal_country\":null,\"is_legal_address_foreign\":false,\"primary_phone\":\"1112223333\",\"secondary_phone\":\"2223334444\",\"is_person\":true,\"email\":\"cgrimes@qwinixtech.com\",\"is_cip_satisfied\":false,\"portal_investor_number\":\"yourinvestornumber\",\"created_by_ip_address\":\"192.168.2.61\",\"Assets\":[{\"id\":471277,\"description\":\"ACME Wealth Agriculture 101, LLC\",\"number\":\"2000001\",\"sold_date\":null,\"market_value\":250,\"Transactions\":[]}],\"Transactions\":[{\"id\":681354,\"account_id\":81690,\"asset_id\":null,\"date\":\"2015-01-02T00:00:00\",\"reference\":\"ref123\",\"description\":\"Cash Deposit\",\"amount\":5000,\"status\":\"Processed\",\"created_by_ip_address\":\"123.456.789.012\"}]}")
205
+ account = CrowdPay::Account.find(account_id)
206
+ expect(account).to be_an(CrowdPay::Account)
207
+ expect(account.assets.count).to be(1)
208
+ end
209
+ end
210
+
211
+ context "negative case" do
212
+ it "should return an account object with errors in it if account_id is invalid" do
213
+ account_id = "invalid_account_id"
214
+ stub_request(:get, "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}").to_return(:status => 405, :body => "{\"Message\":\"The requested resource does not support http method 'GET'.\"}")
215
+ account = CrowdPay::Account.find(account_id)
216
+ expect(account).to be_an(CrowdPay::Account)
217
+ expect(account.errors[:api]).to eq(["The requested resource does not support http method 'GET'."])
218
+ end
219
+ end
220
+ end
221
+
222
+ context "get account with Transaction" do
223
+ context "positive case" do
224
+ it "should get transaction with account" do
225
+ account_id = "83017"
226
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}/Transaction"
227
+ stub_request(:get, url).to_return(:status => 200, :body => "{\"id\":9876544,\"number\":\"$1000605486\",\"portal_account_number\":\"youraccountnumber\",\"investor_id\":78548,\"name_1\":\"InvestorFirst InvestorMiddle InvestorLast\",\"name_2\":null,\"name_3\":null,\"name_4\":null,\"mailing_address_1\":\"123 Ave A\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":true,\"available_balance\":0.00,\"current_balance\":0.00,\"is_cip_satisfied\":false,\"draft_account_type_id\":1,\"draft_routing_number\":\"*****0870\",\"draft_account_number\":\"******7890\",\"draft_account_name\":\"First Last\",\"status_id\":1,\"account_type_id\":12,\"w9_code_id\":1,\"contact_name\":\"InvestorFirst InvestorLast\",\"contact_phone\":\"8061234567\",\"contact_email\":\"fi+rst.l+ast@somewhere.com\",\"idology_id\":123456,\"created_by_ip_address\":\"192.168.2.126\",\"Assets\":[],\"Transactions\":[]}")
228
+ account_with_transaction = CrowdPay::Account.find_with_transactions(account_id)
229
+ expect(account_with_transaction).to be_an(CrowdPay::Account)
230
+ end
231
+ end
232
+
233
+ context "negative case" do
234
+ it "should not get transaction with account" do
235
+ account_id = "83017"
236
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}/Transaction"
237
+ stub_request(:get, url).to_return(:status => 405, :body => "{\"Message\":\"The requested resource does not support http method 'GET'.\"}")
238
+ account_with_transaction = CrowdPay::Account.find_with_transactions(account_id)
239
+ expect(account_with_transaction).to be_an(CrowdPay::Account)
240
+ end
241
+ end
242
+ end
243
+
244
+ context "update account" do
245
+ context "positive case" do
246
+ it "should update account" do
247
+ account_id = "83017"
248
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}"
249
+ account_attributes = FactoryGirl.attributes_for(:account)
250
+ stub_request(:put, url).to_return(:status => 200, :body => "{\"id\":82980,\"number\":\"$1000605486\",\"portal_account_number\":\"youraccountnumber\",\"investor_id\":78548,\"name_1\":\"InvestorFirst InvestorMiddle InvestorLast\",\"name_2\":null,\"name_3\":null,\"name_4\":null,\"mailing_address_1\":\"prakash\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":true,\"available_balance\":0.00,\"current_balance\":0.00,\"is_cip_satisfied\":false,\"draft_account_type_id\":1,\"draft_routing_number\":\"*****0870\",\"draft_account_number\":\"******7890\",\"draft_account_name\":\"First Last\",\"status_id\":1,\"account_type_id\":12,\"w9_code_id\":1,\"contact_name\":\"InvestorFirst InvestorLast\",\"contact_phone\":\"8061234567\",\"contact_email\":\"fi+rst.l+ast@somewhere.com\",\"idology_id\":123456,\"created_by_ip_address\":\"192.168.2.126\",\"Assets\":[],\"Transactions\":[]}")
251
+ update_account = CrowdPay::Account.update(account_id, account_attributes)
252
+ expect(update_account).to be_an(CrowdPay::Account)
253
+ end
254
+ end
255
+
256
+ context "negative case" do
257
+ it "should not update account" do
258
+ account_id = "invalid_account_id"
259
+ url = "https://test.crowdpay.com/Crowdfunding/api/Account/#{account_id}"
260
+ account_attributes = FactoryGirl.attributes_for(:account)
261
+ stub_request(:put, url).to_return(:status => 405, :body => "{\"Message\":\"The requested resource does not support http method 'put'.\"}")
262
+ update_account = CrowdPay::Account.update(account_id, {})
263
+ expect(update_account).to be_an(CrowdPay::Account)
264
+ end
265
+ end
266
+ end
267
+
268
+ context "get_all_assets" do
269
+ context "positive case" do
270
+ it "should get all assets" do
271
+ account_id = "82980"
272
+ stub_request(:get, "https://test.crowdpay.com/Crowdfunding/api/V2/Account/#{account_id}/Assets/All").to_return(:status => 200, :body => "{\"id\":82980,\"number\":\"$1000605486\",\"portal_account_number\":\"youraccountnumber\",\"investor_id\":78548,\"name_1\":\"InvestorFirst InvestorMiddle InvestorLast\",\"name_2\":null,\"name_3\":null,\"name_4\":null,\"mailing_address_1\":\"prakash\",\"mailing_address_2\":null,\"mailing_city\":\"Somewhere\",\"mailing_state\":\"TX\",\"mailing_zip\":\"79109\",\"mailing_country\":null,\"is_mailing_address_foreign\":true,\"available_balance\":0.00,\"current_balance\":0.00,\"is_cip_satisfied\":false,\"draft_account_type_id\":1,\"draft_routing_number\":\"*****0870\",\"draft_account_number\":\"******7890\",\"draft_account_name\":\"First Last\",\"status_id\":1,\"account_type_id\":12,\"w9_code_id\":1,\"contact_name\":\"InvestorFirst InvestorLast\",\"contact_phone\":\"8061234567\",\"contact_email\":\"fi+rst.l+ast@somewhere.com\",\"idology_id\":123456,\"created_by_ip_address\":\"192.168.2.126\",\"Assets\":[{\"id\":471277,\"description\":\"ACME Wealth Agriculture 101, LLC\",\"number\":\"2000001\",\"sold_date\":\"null\",\"market_value\":\"250\",\"Transactions\":[]}]}")
273
+ asset = CrowdPay::Account.find_with_assets(account_id).assets.first
274
+ expect(asset).to be_an(CrowdPay::Asset)
275
+ end
276
+ end
277
+
278
+ context "negative case" do
279
+ it "should not get asset" do
280
+ account_id = "invalid_account_id"
281
+ stub_request(:get, "https://test.crowdpay.com/Crowdfunding/api/V2/Account/#{account_id}/Assets/All").to_return(:status => 405, :body => "{\"Message\":\"The requested resource does not support http method 'GET'.\"}")
282
+ asset = CrowdPay::Account.find_with_assets(account_id).assets
283
+ expect(asset).to eq(nil)
284
+ end
285
+ end
286
+ end
287
+ end