subscriptor_client 0.0.2

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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +22 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +31 -0
  7. data/Rakefile +6 -0
  8. data/lib/subscriptor_client/base.rb +17 -0
  9. data/lib/subscriptor_client/entities_client.rb +59 -0
  10. data/lib/subscriptor_client/subscriptions_client.rb +56 -0
  11. data/lib/subscriptor_client/version.rb +3 -0
  12. data/lib/subscriptor_client.rb +27 -0
  13. data/spec/fixtures/vcr_cassettes/add_credits_success.yml +58 -0
  14. data/spec/fixtures/vcr_cassettes/create_success.yml +58 -0
  15. data/spec/fixtures/vcr_cassettes/destroy_success.yml +54 -0
  16. data/spec/fixtures/vcr_cassettes/index_success.yml +52 -0
  17. data/spec/fixtures/vcr_cassettes/show_success.yml +52 -0
  18. data/spec/fixtures/vcr_cassettes/subscriptions/add_credits_success.yml +58 -0
  19. data/spec/fixtures/vcr_cassettes/subscriptions/create_success.yml +58 -0
  20. data/spec/fixtures/vcr_cassettes/subscriptions/destroy_success.yml +54 -0
  21. data/spec/fixtures/vcr_cassettes/subscriptions/index_success.yml +52 -0
  22. data/spec/fixtures/vcr_cassettes/subscriptions/remove_credits_success.yml +58 -0
  23. data/spec/fixtures/vcr_cassettes/subscriptions/show_success.yml +52 -0
  24. data/spec/fixtures/vcr_cassettes/subscriptions/update_success.yml +58 -0
  25. data/spec/spec_helper.rb +14 -0
  26. data/spec/subscriptor_client/base_spec.rb +13 -0
  27. data/spec/subscriptor_client/entities_client_spec.rb +74 -0
  28. data/spec/subscriptor_client/subscriptions_client_spec.rb +106 -0
  29. data/subscriptor_client.gemspec +33 -0
  30. metadata +228 -0
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://subscriptor.herokuapp.com/api/v1/subscriptions/1?api_key=5&api_password=subscriptor_test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Date:
24
+ - Sat, 17 Jan 2015 21:32:46 GMT
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"d2ce28b9a7fd7e4407e2b0fd499b7fe4"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ Set-Cookie:
40
+ - request_method=DELETE; path=/
41
+ X-Request-Id:
42
+ - 902f152d-2739-4f20-be50-186d1308e9c5
43
+ X-Runtime:
44
+ - '0.234317'
45
+ Transfer-Encoding:
46
+ - chunked
47
+ Via:
48
+ - 1.1 vegur
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"id":1}'
52
+ http_version:
53
+ recorded_at: Sat, 17 Jan 2015 21:32:46 GMT
54
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://subscriptor.herokuapp.com/api/v1/subscriptions?api_key=5&api_password=subscriptor_test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Date:
24
+ - Sat, 17 Jan 2015 21:32:44 GMT
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"4da1371f59548327fc476dec13f6f0f9"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - b15c8b5a-3104-4dcf-9c16-c6f74f316beb
41
+ X-Runtime:
42
+ - '0.234503'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Via:
46
+ - 1.1 vegur
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"subscriptions":[]}'
50
+ http_version:
51
+ recorded_at: Sat, 17 Jan 2015 21:32:45 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://subscriptor.herokuapp.com/api/v1/subscriptions/2/remove_credits
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"5","api_password":"subscriptor_test","credits":2}'
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ Content-Length:
17
+ - '61'
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Date:
28
+ - Sat, 17 Jan 2015 22:32:07 GMT
29
+ Connection:
30
+ - keep-alive
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Etag:
40
+ - '"d6aa04eb9433df5b4b490f71e4742fff"'
41
+ Cache-Control:
42
+ - max-age=0, private, must-revalidate
43
+ Set-Cookie:
44
+ - request_method=PUT; path=/
45
+ X-Request-Id:
46
+ - bcf20dd1-3c7d-435d-9ca4-162374c1e274
47
+ X-Runtime:
48
+ - '0.235862'
49
+ Transfer-Encoding:
50
+ - chunked
51
+ Via:
52
+ - 1.1 vegur
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"credits_remaining":2,"id":2,"entity_id":4,"credits":2,"created_at":"2015-01-17T22:28:06.375Z","updated_at":"2015-01-17T22:32:08.432Z"}'
56
+ http_version:
57
+ recorded_at: Sat, 17 Jan 2015 22:32:08 GMT
58
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://subscriptor.herokuapp.com/api/v1/subscriptions/1?api_key=5&api_password=subscriptor_test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Date:
24
+ - Sat, 17 Jan 2015 21:32:44 GMT
25
+ Connection:
26
+ - keep-alive
27
+ X-Frame-Options:
28
+ - SAMEORIGIN
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Etag:
36
+ - '"33409e3edade6c26ff08594d783f276a"'
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 41991d95-c56c-42bc-a099-3a476b6cc83d
41
+ X-Runtime:
42
+ - '0.235185'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Via:
46
+ - 1.1 vegur
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"credits_remaining":0,"id":1,"entity_id":4,"credits":0,"created_at":"2015-01-17T21:32:45.445Z","updated_at":"2015-01-17T21:32:45.445Z"}'
50
+ http_version:
51
+ recorded_at: Sat, 17 Jan 2015 21:32:46 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://subscriptor.herokuapp.com/api/v1/subscriptions/1
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"5","api_password":"subscriptor_test","credits":2}'
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Type:
15
+ - application/json
16
+ Content-Length:
17
+ - '61'
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Date:
28
+ - Sat, 17 Jan 2015 21:32:45 GMT
29
+ Connection:
30
+ - keep-alive
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Etag:
40
+ - '"d282051923b9ea55dec7d8b396b87f93"'
41
+ Cache-Control:
42
+ - max-age=0, private, must-revalidate
43
+ Set-Cookie:
44
+ - request_method=PUT; path=/
45
+ X-Request-Id:
46
+ - 210b8a81-2ad0-42f4-a603-a4bc06ab0349
47
+ X-Runtime:
48
+ - '0.267086'
49
+ Transfer-Encoding:
50
+ - chunked
51
+ Via:
52
+ - 1.1 vegur
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"credits_remaining":2,"id":1,"entity_id":4,"credits":2,"created_at":"2015-01-17T21:32:45.445Z","updated_at":"2015-01-17T21:32:46.298Z"}'
56
+ http_version:
57
+ recorded_at: Sat, 17 Jan 2015 21:32:46 GMT
58
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,14 @@
1
+ require 'subscriptor_client'
2
+ require 'vcr'
3
+ require 'coveralls'
4
+
5
+ VCR.configure do |c|
6
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
7
+ c.hook_into :webmock
8
+ end
9
+
10
+ Coveralls.wear!
11
+
12
+ class SpecHelper
13
+ end
14
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'rspec/collection_matchers'
3
+ require 'subscriptor_client'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
8
+ c.hook_into :webmock
9
+ end
10
+
11
+ describe SubscriptorClient::Base do
12
+ pending 'add specs'
13
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'rspec/collection_matchers'
3
+
4
+ describe SubscriptorClient::Base do
5
+ let(:config) do
6
+ {
7
+ api_key: '5',
8
+ api_password: 'subscriptor_test',
9
+ host: 'http://subscriptor.herokuapp.com'
10
+ }
11
+ end
12
+
13
+ let(:client) do
14
+ SubscriptorClient.register_config(:test, config)
15
+ SubscriptorClient.new(:test)
16
+ end
17
+
18
+ subject do
19
+ client.entities
20
+ end
21
+
22
+ describe '#index' do
23
+ it 'returns all entities of the client' do
24
+ VCR.use_cassette('index_success') do
25
+ response = subject.index.json
26
+
27
+ expect(response['entities']).to eq []
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '#create' do
33
+ it 'returns an entity of the client' do
34
+ VCR.use_cassette('create_success') do
35
+ response = subject.create.json
36
+
37
+ expect(response['id']).to eq 1
38
+ expect(response['created_at']).not_to be nil
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#add_credits' do
44
+ it 'returns an entity of the client' do
45
+ VCR.use_cassette('add_credits_success') do
46
+ response = subject.add_credits(4, credits: 2).json
47
+
48
+ expect(response['id']).to eq 4
49
+ expect(response['remaining_credits']).to eq 4
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#show' do
55
+ it 'returns an entity of the client' do
56
+ VCR.use_cassette('show_success') do
57
+ response = subject.show(1).json
58
+
59
+ expect(response['id']).to eq 1
60
+ expect(response['created_at']).not_to be nil
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#destroy' do
66
+ it 'returns an entity of the client' do
67
+ VCR.use_cassette('destroy_success') do
68
+ response = subject.destroy(1).json
69
+
70
+ expect(response['id']).to eq 1
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+ require 'rspec/collection_matchers'
3
+
4
+ describe SubscriptorClient::SubscriptionsClient do
5
+ let(:config) do
6
+ {
7
+ api_key: '5',
8
+ api_password: 'subscriptor_test',
9
+ host: 'http://subscriptor.herokuapp.com'
10
+ }
11
+ end
12
+
13
+ let(:client) do
14
+ SubscriptorClient.register_config(:test, config)
15
+ SubscriptorClient.new(:test)
16
+ end
17
+
18
+ subject do
19
+ client.subscriptions
20
+ end
21
+
22
+ let(:subscription_params) do
23
+ {
24
+ credits: 0, entity_id: 4
25
+ }
26
+ end
27
+
28
+ describe '#index' do
29
+ it 'returns all entities of the client' do
30
+ VCR.use_cassette('subscriptions/index_success') do
31
+ response = subject.index.json
32
+
33
+ expect(response['subscriptions']).to eq []
34
+ end
35
+ end
36
+ end
37
+
38
+ describe '#create' do
39
+ it 'returns an entity of the client' do
40
+ VCR.use_cassette('subscriptions/create_success') do
41
+ response = subject.create(subscription_params).json
42
+
43
+ expect(response['id']).to eq 1
44
+ expect(response['entity_id']).to eq subscription_params[:entity_id]
45
+ expect(response['credits']).to eq subscription_params[:credits]
46
+
47
+ expect(response['created_at']).not_to be nil
48
+ end
49
+ end
50
+ end
51
+
52
+ describe '#show' do
53
+ it 'returns an entity of the client' do
54
+ VCR.use_cassette('subscriptions/show_success') do
55
+ response = subject.show(1).json
56
+
57
+ expect(response['id']).to eq 1
58
+
59
+ expect(response['created_at']).not_to be nil
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#add_credits' do
65
+ it 'returns an entity of the client' do
66
+ VCR.use_cassette('subscriptions/add_credits_success') do
67
+ response = subject.add_credits(2, credits: 2).json
68
+
69
+ expect(response['id']).to eq 2
70
+ expect(response['credits']).to eq 4
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '#remove_credits' do
76
+ it 'returns an entity of the client' do
77
+ VCR.use_cassette('subscriptions/remove_credits_success') do
78
+ response = subject.remove_credits(2, credits: 2).json
79
+
80
+ expect(response['id']).to eq 2
81
+ expect(response['credits']).to eq 2
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#update' do
87
+ it 'returns an entity of the client' do
88
+ VCR.use_cassette('subscriptions/update_success') do
89
+ response = subject.update(1, credits: 2).json
90
+
91
+ expect(response['id']).to eq 1
92
+ expect(response['credits']).to eq 2
93
+ end
94
+ end
95
+ end
96
+
97
+ describe '#destroy' do
98
+ it 'returns an entity of the client' do
99
+ VCR.use_cassette('subscriptions/destroy_success') do
100
+ response = subject.destroy(1).json
101
+
102
+ expect(response['id']).to eq 1
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'subscriptor_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "subscriptor_client"
8
+ spec.version = SubscriptorClient::VERSION
9
+ spec.authors = ["johnmcconnell"]
10
+ spec.email = ["johnnyillinois@gmail.com"]
11
+ spec.summary = %q{A client for the subscriptor gem.}
12
+ spec.description = %q{A client for the subscriptor gem.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'rest-client', '~> 1.7.2'
22
+ spec.add_dependency 'json_client', '~> 0.1.0'
23
+
24
+ spec.add_development_dependency "simplecov", "~> 0.8.0"
25
+ spec.add_development_dependency "coveralls", "~> 0.7.0"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.6"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "rspec-collection_matchers"
31
+ spec.add_development_dependency "vcr"
32
+ spec.add_development_dependency "webmock"
33
+ end