btcjammer 0.1.0

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,32 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'ostruct'
4
+
5
+ module BTCJammer
6
+ # https://btcjam.com/faq/api
7
+ class SubmitDocuments
8
+ def self.create_identity_check(access_token, params)
9
+ token = BTCJammer.get_client access_token
10
+ response = token.post("#{API_URL}/identity_checks.json", body: { identity_check: params.to_json })
11
+
12
+ result = OpenStruct.new JSON.parse(response.body)
13
+ OpenStruct.new(result.identity_check)
14
+ end
15
+
16
+ def self.create_addr_check(access_token, params)
17
+ token = BTCJammer.get_client access_token
18
+ response = token.post("#{API_URL}/addr_checks.json", body: { addr_checks: params.to_json })
19
+
20
+ result = OpenStruct.new JSON.parse(response.body)
21
+ OpenStruct.new(result.addr_check)
22
+ end
23
+
24
+ def self.create_credit_check(access_token, params)
25
+ token = BTCJammer.get_client access_token
26
+ response = token.post("#{API_URL}/credit_checks.json", body: { credit_checks: params.to_json })
27
+
28
+ result = OpenStruct.new JSON.parse(response.body)
29
+ OpenStruct.new(result.credit_check)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'ostruct'
4
+
5
+ module BTCJammer
6
+ # No official docs, this method is alluded to.
7
+ class Terms
8
+ def self.all
9
+ response = Faraday.get("#{API_PUBLIC_URL}/terms.json")
10
+ JSON.parse(response.body).collect { |t| OpenStruct.new t }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,71 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'ostruct'
4
+ require 'oauth'
5
+
6
+ module BTCJammer
7
+ # Contains user authenticated API calls https://btcjam.com/faq/api
8
+ class Users
9
+ def self.create(email, password)
10
+ url = "#{API_URL}/"
11
+ url += "users.json?appid=#{BTCJammer.client_id}&"
12
+ url += "secret=#{BTCJammer.client_secret}"
13
+
14
+ response = Faraday.post(url, email: email, password: password)
15
+
16
+ JSON.parse(response.body)
17
+ end
18
+
19
+ def self.profile(access_token)
20
+ BTCJammer.api_call(access_token, :me, :object)
21
+ end
22
+
23
+ def self.open_listings(access_token)
24
+ BTCJammer.api_call(access_token, :my_open_listings, :array)
25
+ end
26
+
27
+ def self.receivables(access_token)
28
+ OpenStruct.new BTCJammer.api_call(access_token, :my_receivables, :object).user
29
+ end
30
+
31
+ def self.payables(access_token)
32
+ OpenStruct.new BTCJammer.api_call(access_token, :my_payables, :object).user
33
+ end
34
+
35
+ def self.identity_checks(access_token)
36
+ BTCJammer.api_call(access_token, :identity_checks, :object)
37
+ .identity_checks.collect do |i|
38
+ OpenStruct.new i
39
+ end
40
+ end
41
+
42
+ def self.addr_checks(access_token)
43
+ BTCJammer.api_call(access_token, :addr_checks, :object).addr_checks.collect do |i|
44
+ OpenStruct.new i
45
+ end
46
+ end
47
+
48
+ def self.credit_checks(access_token)
49
+ BTCJammer.api_call(access_token, :credit_checks, :object)
50
+ .credit_checks.collect do |i|
51
+ OpenStruct.new i
52
+ end
53
+ end
54
+
55
+ def self.invest(access_token, listing_id, amount)
56
+ token = BTCJammer.get_client access_token
57
+ response = token.post("#{API_URL}/investments.json",
58
+ body: { listing_id: listing_id, amount: amount })
59
+
60
+ investment = OpenStruct.new(JSON.parse(response.body)).listing_investment
61
+ OpenStruct.new investment
62
+ end
63
+
64
+ def self.automatic_plans(access_token)
65
+ BTCJammer.api_call(access_token, :automatic_plans, :object)
66
+ .automatic_plans.collect do |i|
67
+ OpenStruct.new i
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,4 @@
1
+ # Holds all the API magic!
2
+ module BTCJammer
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,19 @@
1
+ require './test/test_helper'
2
+
3
+ describe 'BTCJammer::AutomaticPlanTemplates' do
4
+ it 'should exist for sure' do
5
+ assert BTCJammer::AutomaticPlanTemplates
6
+ end
7
+
8
+ it 'should return a list of all supported automatic plan templates' do
9
+ VCR.use_cassette('automatic_plan_templates') do
10
+ templates = BTCJammer::AutomaticPlanTemplates.all
11
+
12
+ assert templates.is_a? Array
13
+ assert templates.length == 3
14
+
15
+ assert templates.first.id == 1
16
+ assert templates.first.name == 'Conservative'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require './test/test_helper'
2
+
3
+ describe 'BTCJammer::Currencies' do
4
+ it 'should exist for sure' do
5
+ assert BTCJammer::Currencies
6
+ end
7
+
8
+ it 'should return a list of all supported currencies' do
9
+ VCR.use_cassette('currencies') do
10
+ currencies = BTCJammer::Currencies.all
11
+
12
+ assert currencies.is_a? Array
13
+ assert currencies.length == 7
14
+ assert currencies.first.id == 1
15
+ assert currencies.first.name == 'Bitcoin'
16
+ assert currencies.first.conversion_to_btc == '1.0'
17
+ assert currencies.first.conversion_from_btc == '1.0'
18
+ assert currencies.first.iso_code == 'BTC'
19
+ assert currencies.first.symbol == '฿'
20
+ assert currencies.first.income_enabled == false
21
+ assert currencies.first.combined_code == '฿ BTC'
22
+ assert currencies.first.locale_code.nil?
23
+ assert currencies.first.country_code.nil?
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require './test/test_helper'
2
+
3
+ describe 'BTCJammer::EmploymentStatuses' do
4
+ it 'should exist for sure' do
5
+ assert BTCJammer::EmploymentStatuses
6
+ end
7
+
8
+ it 'should return a list of all supported employment statuses' do
9
+ VCR.use_cassette('employee_statuses') do
10
+ statuses = BTCJammer::EmploymentStatuses.all
11
+
12
+ assert statuses.is_a? Array
13
+ assert statuses.length == 5
14
+
15
+ assert statuses.first.id == 1
16
+ assert statuses.first.name == 'Employee'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://btcjam.com/automatic_plan_templates.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ Cache-Control:
22
+ - no-cache
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Date:
26
+ - Mon, 12 Oct 2015 06:07:09 GMT
27
+ Server:
28
+ - nginx/1.6.2 + Phusion Passenger 4.0.50
29
+ Status:
30
+ - 401 Unauthorized
31
+ Strict-Transport-Security:
32
+ - max-age=31536000
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Frame-Options:
36
+ - ALLOW-FROM https://www.optimizely.com/
37
+ X-Powered-By:
38
+ - Phusion Passenger 4.0.50
39
+ X-Request-Id:
40
+ - ccaa3137-29bd-4bce-9250-bd32b58560cf
41
+ X-Runtime:
42
+ - '0.018190'
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Connection:
48
+ - keep-alive
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"error":"You need to log in or sign up before continuing."}'
52
+ http_version:
53
+ recorded_at: Mon, 12 Oct 2015 06:07:05 GMT
54
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,95 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://btcjam.com/currencies.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Date:
26
+ - Fri, 09 Oct 2015 07:37:56 GMT
27
+ Server:
28
+ - nginx/1.6.2 + Phusion Passenger 4.0.50
29
+ Set-Cookie:
30
+ - XSRF-TOKEN=khiUdAJr4uR4IrZBP3%2FJ%2BdFJ%2FdnV1xsyE%2F0GDgqrGeE8o0yR7GrT9ZSEDEWj3X10ZfgKAnXmNr4uan4L5haN2g%3D%3D;
31
+ path=/; secure
32
+ - _session_id=3f7209865613cb1d98ee3df8ca5a1ab4; path=/; expires=Fri, 09 Oct
33
+ 2015 13:37:56 -0000; secure; HttpOnly
34
+ Status:
35
+ - 200 OK
36
+ Strict-Transport-Security:
37
+ - max-age=31536000
38
+ Vary:
39
+ - Accept-Encoding
40
+ X-Content-Type-Options:
41
+ - nosniff
42
+ X-Frame-Options:
43
+ - ALLOW-FROM https://www.optimizely.com/
44
+ X-Powered-By:
45
+ - Phusion Passenger 4.0.50
46
+ X-Request-Id:
47
+ - db08f2aa-c0a7-4127-87a0-f816f9aebbde
48
+ X-Runtime:
49
+ - '0.044553'
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ Transfer-Encoding:
53
+ - chunked
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: !binary |-
59
+ Clt7ImlkIjoxLCJuYW1lIjoiQml0Y29pbiIsImNvbnZlcnNpb25fdG9fYnRj
60
+ IjoiMS4wIiwiY29udmVyc2lvbl9mcm9tX2J0YyI6IjEuMCIsImlzb19jb2Rl
61
+ IjoiQlRDIiwic3ltYm9sIjoi4Li/IiwiaW5jb21lX2VuYWJsZWQiOmZhbHNl
62
+ LCJjb21iaW5lZF9jb2RlIjoi4Li/IEJUQyIsImxvY2FsZV9jb2RlIjpudWxs
63
+ LCJjb3VudHJ5X2NvZGUiOm51bGx9LHsiaWQiOjcsIm5hbWUiOiJDb2luZGVz
64
+ a1VTRCIsImNvbnZlcnNpb25fdG9fYnRjIjoiMC4wMDQxMTcyNCIsImNvbnZl
65
+ cnNpb25fZnJvbV9idGMiOiIyNDIuODgxIiwiaXNvX2NvZGUiOiJVU0QiLCJz
66
+ eW1ib2wiOiI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oxMSwibmFtZSI6IkNvaW5kZXNr
83
+ RVVSIiwiY29udmVyc2lvbl90b19idGMiOiIwLjAwNDY0NTczIiwiY29udmVy
84
+ c2lvbl9mcm9tX2J0YyI6IjIxNS4yNTE2IiwiaXNvX2NvZGUiOiJFVVIiLCJz
85
+ eW1ib2wiOiLigqwiLCJpbmNvbWVfZW5hYmxlZCI6dHJ1ZSwiY29tYmluZWRf
86
+ Y29kZSI6IuKCrCBFVVIiLCJsb2NhbGVfY29kZSI6InB0IiwiY291bnRyeV9j
87
+ b2RlIjoiX0V1cm9wZWFuX1VuaW9uIn0seyJpZCI6MTIsIm5hbWUiOiJDb2lu
88
+ ZGVza0lOUiIsImNvbnZlcnNpb25fdG9fYnRjIjoiMC4wMDAwNjM0OSIsImNv
89
+ bnZlcnNpb25fZnJvbV9idGMiOiIxNTc1MC43OTQ0IiwiaXNvX2NvZGUiOiJJ
90
+ TlIiLCJzeW1ib2wiOiLigrkiLCJpbmNvbWVfZW5hYmxlZCI6dHJ1ZSwiY29t
91
+ YmluZWRfY29kZSI6IuKCuSBJTlIiLCJsb2NhbGVfY29kZSI6bnVsbCwiY291
92
+ bnRyeV9jb2RlIjoiaW4ifV0=
93
+ http_version:
94
+ recorded_at: Fri, 09 Oct 2015 07:37:56 GMT
95
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://btcjam.com/employment_statuses.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Date:
26
+ - Fri, 09 Oct 2015 07:37:57 GMT
27
+ Server:
28
+ - nginx/1.6.2 + Phusion Passenger 4.0.50
29
+ Set-Cookie:
30
+ - XSRF-TOKEN=CeOjJtedQNWGsNegq3bQsWSYDJhrHdOw7dRHWU2NGeIcwHf%2Bf4RJjVLT6HpkT7LiBsVCT1137pMGGsYMlkUAyw%3D%3D;
31
+ path=/; secure
32
+ - _session_id=5c2cb7631bce0522fa2d7e5d9b59f8fe; path=/; expires=Fri, 09 Oct
33
+ 2015 13:37:57 -0000; secure; HttpOnly
34
+ Status:
35
+ - 200 OK
36
+ Strict-Transport-Security:
37
+ - max-age=31536000
38
+ Vary:
39
+ - Accept-Encoding
40
+ X-Content-Type-Options:
41
+ - nosniff
42
+ X-Frame-Options:
43
+ - ALLOW-FROM https://www.optimizely.com/
44
+ X-Powered-By:
45
+ - Phusion Passenger 4.0.50
46
+ X-Request-Id:
47
+ - da32deb1-8474-4c9c-9c2d-f62a2a5de457
48
+ X-Runtime:
49
+ - '0.010813'
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ Transfer-Encoding:
53
+ - chunked
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: '[{"id":1,"name":"Employee"},{"id":2,"name":"Worker"},{"id":3,"name":"Self-employed"},{"id":4,"name":"Unemployed"},{"id":5,"name":"Entrepreneur"}]'
59
+ http_version:
60
+ recorded_at: Fri, 09 Oct 2015 07:37:57 GMT
61
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,79 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://btcjam.com/nationalid_types.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Date:
26
+ - Fri, 09 Oct 2015 07:37:57 GMT
27
+ Server:
28
+ - nginx/1.6.2 + Phusion Passenger 4.0.50
29
+ Set-Cookie:
30
+ - XSRF-TOKEN=4gM7qCSqUe0K%2F7PAetIHKRYn8s6MJMtF70nAwynf1yDvQIWdHy%2BJoxnNi%2FVuItipIkZC%2FG5a%2FaQvB7bszq7GNQ%3D%3D;
31
+ path=/; secure
32
+ - _session_id=70d8ec11c69a261e8d456c87ac587b39; path=/; expires=Fri, 09 Oct
33
+ 2015 13:37:57 -0000; secure; HttpOnly
34
+ Status:
35
+ - 200 OK
36
+ Strict-Transport-Security:
37
+ - max-age=31536000
38
+ Vary:
39
+ - Accept-Encoding
40
+ X-Content-Type-Options:
41
+ - nosniff
42
+ X-Frame-Options:
43
+ - ALLOW-FROM https://www.optimizely.com/
44
+ X-Powered-By:
45
+ - Phusion Passenger 4.0.50
46
+ X-Request-Id:
47
+ - afd4d384-e84d-4437-b1a3-95ef1bdcfa62
48
+ X-Runtime:
49
+ - '0.019784'
50
+ X-Xss-Protection:
51
+ - 1; mode=block
52
+ Transfer-Encoding:
53
+ - chunked
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: |2-
59
+
60
+ [
61
+ {
62
+ "id": 1,
63
+ "name": "Driver's License",
64
+ "translated_name": "Driver's License"
65
+ },
66
+ {
67
+ "id": 2,
68
+ "name": "National ID",
69
+ "translated_name": "National ID"
70
+ },
71
+ {
72
+ "id": 3,
73
+ "name": "Passport",
74
+ "translated_name": "Passport"
75
+ }
76
+ ]
77
+ http_version:
78
+ recorded_at: Fri, 09 Oct 2015 07:37:57 GMT
79
+ recorded_with: VCR 2.9.3