rhapsody 0.0.5 → 0.0.6.beta1

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8088ac86323d36432bb5370890e15953b73df4c0
4
- data.tar.gz: 52003fac1439f284a6527d2c70af351de262f5f2
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjBiYTE0NjgwOTM2YTYwN2U2ZjJjM2U4YjUwMTA3YWFhODJjNzMxNA==
5
+ data.tar.gz: !binary |-
6
+ N2YyNzdhZWMwNTgwZTlkZDgwOWFkNzBmYzI5NGIxNDU3NWMzYWRkNQ==
5
7
  SHA512:
6
- metadata.gz: 6d2f39cc994546af711edc463cedb25897d7ec79c3e7686c42c776376a7bf3b9e421e5547d4c6264e7381b447667e61a74c850d1e2f73ad40678cf0dd5c4af2f
7
- data.tar.gz: 2c5ee98b57d719a520bb8c2e5507a48f0327a3b99d1326462c1c9b2d0f7757154fdf3678fe2d851da531455c727d94a7510e045f45df3b4f638c4d54331ea364
8
+ metadata.gz: !binary |-
9
+ MWQ3MTBiZTU1OTBkZmNiMTljZWE5ZmQyMWMwNzE2M2JkMjZkNjk1NDNmNWRi
10
+ MjNlZTFhZTZjZDIzNzA2YzhjYmQxM2MzYjI1NDcwMzUxZDU2MTg2ZGU4MmU3
11
+ ZjI0ZjJhNThkNTE1MzUwZjI3Njg0OTNlYTMwOWEyYTQwZmM1MTI=
12
+ data.tar.gz: !binary |-
13
+ MTY5NjUzYzc0YTQ3NDQ0MWQ4OWI2Zjc1ZjRjOGY1MTc1MmZmYjFjNjM5NWE5
14
+ ZGI5YWMwMTFlZmEzZmZjZDNkOGEwZTA1MmIzNzRkY2VkOTgzYmY4NzI1NDBi
15
+ NWVhMGY2ZDQ0NjM3ZWJhNTIwMGUzYWI4NjY0Y2RlN2Y1OWZkMDU=
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  gem 'faraday', '~> 0.9.0'
7
7
 
8
- group :test do
8
+ group :test, :development do
9
9
  gem 'rspec', '~> 3.0.0'
10
10
  gem 'factory_girl', '~> 4.4.0'
11
11
  gem 'debugger', '~> 1.6.8'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rhapsody (0.0.5)
4
+ rhapsody (0.0.6.beta1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Rhapsody
1
+ # Rhapsody gem
2
2
 
3
- TODO: Write a gem description
3
+ **Still under development**
4
+
5
+ Rhapsody gem provides a Ruby object-oriented interface for Rhapsody API.
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,6 +20,26 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
23
+ ### Setting up a client
24
+
25
+ A client prepares you to make calls to Rhapsody API.
26
+ Here is an example code for setting up a client using
27
+ [implicit method](https://developer.rhapsody.com/api#authentication).
28
+
29
+ ``` ruby
30
+ require 'rhapsody'
31
+
32
+ options = {
33
+ api_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
34
+ api_secret: 'yyyyyyyyyyyy',
35
+ auth_code: 'zzzzzzzzzz',
36
+ redirect_url: 'http://example.com/rhapsody/auth'
37
+ }
38
+
39
+ client = Rhapsody::Client.new(options)
40
+ client.connect
41
+ ```
42
+
21
43
  ### Running tests
22
44
 
23
45
  Rhapsody gem uses RSpec and FactoryGirl.
@@ -35,6 +57,9 @@ config_variables:
35
57
  API_SECRET: "yyyyyyyyyyyy"
36
58
  ```
37
59
 
60
+ 4. `$ bundle install`
61
+
62
+ 5. `$ rspec`
38
63
 
39
64
  ## Contributing
40
65
 
@@ -1,4 +1,4 @@
1
- class Rhapsody::Client
1
+ class Rhapsody::ClientsController
2
2
  attr_accessor :api_key,
3
3
  :api_secret,
4
4
  :auth_code,
@@ -10,25 +10,10 @@ class Rhapsody::Client
10
10
  :refresh_token,
11
11
  :expires_in
12
12
 
13
- class << self
14
- end
15
-
16
- def initialize(options)
17
- @api_key = options[:api_key]
18
- @api_secret = options[:api_secret]
19
- @auth_code = options[:auth_code]
20
- @redirect_url = options[:redirect_url]
21
- end
13
+ OAUTH_PATH = '/oauth/access_token'
22
14
 
23
15
  def connect
24
- host_url = 'https://api.rhapsody.com'
25
- oauth_path = '/oauth/access_token'
26
-
27
- connection = Faraday.new(:url => host_url) do |faraday|
28
- faraday.request :url_encoded
29
- faraday.response :logger
30
- faraday.adapter Faraday.default_adapter
31
- end
16
+ connection = FaradayConnection.prepare_authentication
32
17
 
33
18
  post_hash = {
34
19
  client_id: @api_key,
@@ -39,12 +24,18 @@ class Rhapsody::Client
39
24
  redirect_uri: @redirect_url
40
25
  }
41
26
 
42
- @raw_response = connection.post(oauth_path, post_hash)
27
+ @raw_response = connection.post(OAUTH_PATH, post_hash)
43
28
  @json_response = JSON.parse(@raw_response.env[:body])
44
29
  @response_status = @raw_response.env[:status]
45
30
 
46
31
  @access_token = @json_response['access_token']
47
32
  @refresh_token = @json_response['refresh_token']
48
33
  @expires_in = @json_response['expires_in']
34
+ self
35
+ end
36
+
37
+ def me_account
38
+ members_controller = MembersController.new(@access_token)
39
+ members_controller.account
49
40
  end
50
41
  end
@@ -0,0 +1,23 @@
1
+ class Rhapsody::MembersController
2
+ attr_accessor :path,
3
+ :access_token,
4
+ :raw_reponse,
5
+ :json_response,
6
+ :response_status
7
+
8
+ PARENT_PATH = '/v1/me'
9
+
10
+ def initialize(options)
11
+ @access_token = options[:access_token]
12
+ end
13
+
14
+ # /me/account
15
+ def account
16
+ @path = PARENT_PATH + '/account'
17
+ connection = FaradayConnection.prepare_authorization(access_token)
18
+ @raw_reponse = connection.get(@path)
19
+ @json_response = JSON.parse(@raw_response.env[:body])
20
+ @response_status = @raw_response.env[:status]
21
+ member = Member.new(@json_response)
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Rhapsody::FaradayConnection
2
+ require 'faraday'
3
+
4
+ def self.prepare_authentication
5
+ Faraday.new(:url => Rhapsody::HOST_URL) do |faraday|
6
+ faraday.request :url_encoded
7
+ faraday.response :logger
8
+ faraday.adapter Faraday.default_adapter
9
+ end
10
+ end
11
+
12
+ def self.prepare_authorization(access_token)
13
+ Faraday.new(:url => Rhapsody::HOST_URL) do |faraday|
14
+ faraday.request :url_encoded
15
+ faraday.response :logger
16
+ faraday.adapter Faraday.default_adapter
17
+ faraday.authorization :Bearer, access_token
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ class Rhapsody::Member
2
+ attr_accessor :cobrand,
3
+ :cocat,
4
+ :email,
5
+ :logon,
6
+ :firstName,
7
+ :id,
8
+ :lastName,
9
+ :locale,
10
+ :country,
11
+ :isPublic,
12
+ :billingPartnerCode,
13
+ :catalog,
14
+ :createDate,
15
+ :isSuspended,
16
+ :tierCode,
17
+ :tierName,
18
+ :productCode,
19
+ :productName,
20
+ :expirationDate,
21
+ :trialLengthDays,
22
+ :isTrial,
23
+ :state,
24
+ :canStreamOnWeb,
25
+ :canStreamOnMobile,
26
+ :canStreamOnHomeDevice,
27
+ :canStreamOnPC,
28
+ :canUpgradeStreams,
29
+ :maxStreamCount,
30
+ :isPlayBasedTier,
31
+ :isMonthlyPlayBasedTier,
32
+ :isOneTimePlayBasedTier,
33
+ :totalPlays,
34
+ :playsRemaining
35
+
36
+ def initialize(options)
37
+ if options
38
+ options.each do |key, value|
39
+ instance_variable_set("@#{key}", value)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Rhapsody
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6.beta1"
3
3
  end
data/lib/rhapsody.rb CHANGED
@@ -1,5 +1,12 @@
1
1
  require "rhapsody/version"
2
- require 'rhapsody/models/client'
2
+
3
+ require 'rhapsody/helpers/faraday_connection'
4
+
5
+ require 'rhapsody/controllers/clients_controller'
6
+ require 'rhapsody/controllers/members_controller'
7
+
8
+ require 'rhapsody/models/member'
3
9
 
4
10
  module Rhapsody
11
+ HOST_URL = 'https://api.rhapsody.com'
5
12
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rhapsody::ClientsController do
4
+ it 'has HOST_URL' do
5
+ host_url = Rhapsody::HOST_URL
6
+ expect(host_url).to eql('https://api.rhapsody.com')
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rhapsody::Client do
3
+ describe Rhapsody::MembersController do
4
4
  it '.new' do
5
5
  end
6
6
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rhapsody::FaradayConnection do
4
+ it '#prepare_authentication' do
5
+ faraday_obj = Rhapsody::FaradayConnection.prepare_authentication
6
+ expect(faraday_obj.class.name).to eql('Faraday::Connection')
7
+ end
8
+
9
+ it '#prepare_authorization' do
10
+ faraday_obj = Rhapsody::FaradayConnection.prepare_authorization('fake')
11
+ expect(faraday_obj.class.name).to eql('Faraday::Connection')
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rhapsody::Client do
4
+ it 'has HOST_URL' do
5
+ host_url = Rhapsody::HOST_URL
6
+ expect(host_url).to eql('https://api.rhapsody.com')
7
+ end
8
+
9
+ it '.new' do
10
+ end
11
+
12
+ it '#account' do
13
+ end
14
+ end
@@ -11,6 +11,6 @@ describe Rhapsody do
11
11
  end
12
12
 
13
13
  it 'checks version' do
14
- expect(Rhapsody::VERSION).to eql('0.0.5')
14
+ expect(Rhapsody::VERSION).to eql('0.0.6.beta1')
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhapsody
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Kim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Rhapsody REST API gem provides a Ruby object-oriented interface.
@@ -45,20 +45,25 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".gitignore"
48
+ - .gitignore
49
49
  - Gemfile
50
50
  - Gemfile.lock
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
54
  - lib/rhapsody.rb
55
- - lib/rhapsody/models/client.rb
55
+ - lib/rhapsody/controllers/clients_controller.rb
56
+ - lib/rhapsody/controllers/members_controller.rb
57
+ - lib/rhapsody/helpers/faraday_connection.rb
58
+ - lib/rhapsody/models/member.rb
56
59
  - lib/rhapsody/version.rb
57
60
  - rhapsody.gemspec
58
- - spec/app/rhapsody_spec.rb
59
61
  - spec/config_helper.rb
60
- - spec/factories/clients.rb
61
- - spec/models/client_spec.rb
62
+ - spec/rhapsody/controllers/clients_controller_spec.rb
63
+ - spec/rhapsody/controllers/members_controller_spec.rb
64
+ - spec/rhapsody/helpers/faraday_connection_spec.rb
65
+ - spec/rhapsody/models/member_spec.rb
66
+ - spec/rhapsody/rhapsody_spec.rb
62
67
  - spec/spec_helper.rb
63
68
  homepage: https://github.com/serv/rhapsody
64
69
  licenses:
@@ -70,23 +75,25 @@ require_paths:
70
75
  - lib
71
76
  required_ruby_version: !ruby/object:Gem::Requirement
72
77
  requirements:
73
- - - ">="
78
+ - - ! '>='
74
79
  - !ruby/object:Gem::Version
75
80
  version: '0'
76
81
  required_rubygems_version: !ruby/object:Gem::Requirement
77
82
  requirements:
78
- - - ">="
83
+ - - ! '>'
79
84
  - !ruby/object:Gem::Version
80
- version: '0'
85
+ version: 1.3.1
81
86
  requirements: []
82
87
  rubyforge_project:
83
- rubygems_version: 2.4.1
88
+ rubygems_version: 2.2.2
84
89
  signing_key:
85
90
  specification_version: 4
86
- summary: 'NOT READY: A Ruby object-oriented interface to the Rhapsody REST API'
91
+ summary: ! 'NOT READY: A Ruby object-oriented interface to the Rhapsody REST API'
87
92
  test_files:
88
- - spec/app/rhapsody_spec.rb
89
93
  - spec/config_helper.rb
90
- - spec/factories/clients.rb
91
- - spec/models/client_spec.rb
94
+ - spec/rhapsody/controllers/clients_controller_spec.rb
95
+ - spec/rhapsody/controllers/members_controller_spec.rb
96
+ - spec/rhapsody/helpers/faraday_connection_spec.rb
97
+ - spec/rhapsody/models/member_spec.rb
98
+ - spec/rhapsody/rhapsody_spec.rb
92
99
  - spec/spec_helper.rb
@@ -1,13 +0,0 @@
1
- FactoryGirl.define do
2
- factory :client do
3
- api_key
4
- api_secret
5
- auth_code
6
- redirect_url
7
- raw_reponse
8
- json_response
9
- response_status
10
- access_token
11
- refresh_token
12
- end
13
- end