nov-smartfm 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -39,9 +39,13 @@
39
39
 
40
40
  == 0.3.1
41
41
 
42
- * add sessions API support
42
+ * add sessions API calls
43
43
  * fixed extract API bugs
44
44
 
45
45
  == 0.4.0
46
46
 
47
- * OAuth DELETE calls works fine now.
47
+ * OAuth DELETE calls works fine now.
48
+
49
+ == 1.0.0
50
+
51
+ * add friends, followers, likes and notifications API calls
@@ -1,7 +1,7 @@
1
1
  module Smartfm::Version
2
2
  MAJOR = 1
3
3
  MINOR = 0
4
- REVISION = 0
4
+ REVISION = 2
5
5
  class << self
6
6
  def to_version
7
7
  "#{MAJOR}.#{MINOR}.#{REVISION}"
@@ -1,6 +1,6 @@
1
1
  class Smartfm::List < Smartfm::Base
2
2
  ATTRIBUTES = [:id, :title, :description, :icon, :square_icon, :item_count, :user_count, :iknow, :dictation, :brainspeed,
3
- :language, :translation_language, :list_type, :transcript, :embed, :tags, :media_entry,
3
+ :language, :translation_language, :item_type, :transcript, :embed, :tags, :media_entry,
4
4
  :attribution_license_id, :items, :sentences, :user]
5
5
  READONLY_ATTRIBUTES = [:id, :icon, :item_count, :user_count, :iknow, :dictation, :brainspeed, :user]
6
6
  attr_accessor *(ATTRIBUTES - READONLY_ATTRIBUTES)
@@ -50,7 +50,7 @@ class Smartfm::List < Smartfm::Base
50
50
  @dictation = Application.new(common_settings.merge(:dictation => params[:dictation]))
51
51
  @brainspeed = Application.new(common_settings.merge(:brainspeed => params[:brainspeed]))
52
52
  end
53
- @list_type = params[:list_type] # for list creation
53
+ @item_type = params[:item_type] # for list creation
54
54
  @transcript = params[:transcript] # for list creation
55
55
  @embed = params[:embed] # for list creation
56
56
  @tags = params[:tags] # for list creation
@@ -72,7 +72,8 @@ class Smartfm::List < Smartfm::Base
72
72
  end
73
73
 
74
74
  def add_item(auth, item)
75
- self.rest_client.add_item(auth, {:id => self.id, :item_id => item.id})
75
+ # id is used for item_id only here..
76
+ self.rest_client.add_item(auth, {:list_id => self.id, :id => item.id})
76
77
  end
77
78
 
78
79
  def delete_item(auth, item)
@@ -90,10 +91,7 @@ class Smartfm::List < Smartfm::Base
90
91
  'list[translation_language]' => self.translation_language || 'ja'
91
92
  }
92
93
  # Optional attributes
93
- if self.list_type
94
- post_data['list[type]'] = self.list_type
95
- end
96
- [:transcript, :embed, :tags, :media_entry, :author, :author_url, :attribution_license_id ].each do |key|
94
+ [:transcript, :embed, :tags, :item_type].each do |key|
97
95
  if self.send("#{key}")
98
96
  post_data["list[#{key}]"] = self.send("#{key}")
99
97
  end
@@ -17,7 +17,7 @@ class Smartfm::Notification < Smartfm::Base
17
17
  @context = params[:context]
18
18
  end
19
19
 
20
- private
20
+ protected
21
21
 
22
22
  def to_post_data
23
23
  {:message => self.message}
@@ -5,11 +5,11 @@ module Smartfm::ActsAsLikable
5
5
  self.deserialize(hash, :as => Smartfm::Like) || []
6
6
  end
7
7
 
8
- def like!(auth, params)
8
+ def like!(auth, params = {})
9
9
  self.rest_client.like!(auth, params.merge(:id => self.id))
10
10
  end
11
11
 
12
- def unlike!(auth, params)
12
+ def unlike!(auth, params = {})
13
13
  self.rest_client.unlike!(auth, params.merge(:id => self.id))
14
14
  end
15
15
 
@@ -12,7 +12,7 @@ module Smartfm::PrivateContent
12
12
  end
13
13
 
14
14
  def create(auth, params = {})
15
- self.new(params).save
15
+ self.new(params).save(auth)
16
16
  end
17
17
  end
18
18
 
@@ -11,8 +11,8 @@ module Smartfm::PublicContent
11
11
  self.deserialize(hash) || []
12
12
  end
13
13
 
14
- def find(list_id, params = {})
15
- params[:id] = list_id
14
+ def find(obj_id, params = {})
15
+ params[:id] = obj_id
16
16
  hash = self.rest_client.find(params)
17
17
  self.deserialize(hash)
18
18
  end
@@ -34,12 +34,15 @@ module Smartfm::PublicContent
34
34
 
35
35
  module InstanceMethods
36
36
  def save(auth)
37
- begin
38
- obj_id = self.rest_client.create(auth, self.to_post_data)
39
- rescue
40
- return false
37
+ result = self.rest_client.create(auth, self.to_post_data)
38
+ case result
39
+ when Hash
40
+ self.deserialize(result)
41
+ when String
42
+ self.class.find(result)
43
+ else
44
+ true
41
45
  end
42
- self.find(obj_id)
43
46
  end
44
47
 
45
48
  def delete(auth)
@@ -147,18 +147,18 @@ class Smartfm::RestClient::Base
147
147
  case auth.mode
148
148
  when :oauth
149
149
  response = auth.auth_token.get(path, http_header)
150
- handle_rest_response(response, :text)
150
+ handle_rest_response(response, :json)
151
151
  when :basic_auth
152
152
  http_connect do
153
153
  get_req = Net::HTTP::Get.new(path, http_header)
154
154
  get_req.basic_auth(auth.account.username, auth.account.password)
155
- [get_req, :text]
155
+ [get_req, :json]
156
156
  end
157
157
  end
158
158
  end
159
159
 
160
160
  def self.http_post(auth, path, params = {})
161
- self.api_key_required
161
+ api_key_required
162
162
  params.merge!(:api_key => self.config.api_key)
163
163
  case auth.mode
164
164
  when :oauth
@@ -175,7 +175,7 @@ class Smartfm::RestClient::Base
175
175
  end
176
176
 
177
177
  def self.http_delete(auth, path, params = {})
178
- self.api_key_required
178
+ api_key_required
179
179
  params.merge!(:api_key => self.config.api_key)
180
180
  path = "#{path}?#{params.to_http_str}"
181
181
  case auth.mode
@@ -8,7 +8,7 @@ class Smartfm::RestClient::List < Smartfm::RestClient::Base
8
8
  :matching => {:path => '/lists/matching/__keyword__'},
9
9
  :likes => {:path => '/lists/__id__/likes' },
10
10
  :create => {:path => '/lists', :http_method => :post},
11
- :add_item => {:path => '/lists/__id__/items', :http_method => :post},
11
+ :add_item => {:path => '/lists/__list_id__/items', :http_method => :post}, # id is used for item_id here..
12
12
  :like! => {:path => '/lists/__id__/likes', :http_method => :post},
13
13
  :delete => {:path => '/lists/__id__', :http_method => :delete},
14
14
  :delete_item => {:path => '/lists/__id__/items/__item_id__', :http_method => :delete},
@@ -13,8 +13,8 @@ class Smartfm::RestClient::User < Smartfm::RestClient::Base
13
13
  :notifications => {:path => '/users/__username__/notifications'},
14
14
  :matching => {:path => '/users/matching/__keyword__' },
15
15
  :study_results => {:path => '/users/__username__/study_results/__application__'},
16
- :follow! => {:path => '/users/__username__/friends', :http_method => :post},
17
- :unfollow! => {:path => '/users/__username__/friends', :http_method => :delete}
16
+ :follow! => {:path => '/friends', :http_method => :post},
17
+ :unfollow! => {:path => '/friends/__username__', :http_method => :delete}
18
18
  }
19
19
 
20
20
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nov-smartfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov
@@ -54,22 +54,22 @@ files:
54
54
  - spec/smartfm/core/auth_spec.rb
55
55
  - spec/smartfm/core/config_spec.rb
56
56
  - spec/smartfm/core/version_spec.rb
57
- - spec/smartfm/model
58
- - spec/smartfm/model/base_spec.rb
59
- - spec/smartfm/model/item_spec.rb
60
- - spec/smartfm/model/like_spec.rb
61
- - spec/smartfm/model/list_spec.rb
62
- - spec/smartfm/model/notification_spec.rb
63
- - spec/smartfm/model/sentence_spec.rb
64
- - spec/smartfm/model/user_spec.rb
65
- - spec/smartfm/rest_client
66
- - spec/smartfm/rest_client/base_spec.rb
67
- - spec/smartfm/rest_client/item_spec.rb
68
- - spec/smartfm/rest_client/like_spec.rb
69
- - spec/smartfm/rest_client/list_spec.rb
70
- - spec/smartfm/rest_client/notification_spec.rb
71
- - spec/smartfm/rest_client/sentence_spec.rb
72
- - spec/smartfm/rest_client/user_spec.rb
57
+ - spec/smartfm/models
58
+ - spec/smartfm/models/base_spec.rb
59
+ - spec/smartfm/models/item_spec.rb
60
+ - spec/smartfm/models/like_spec.rb
61
+ - spec/smartfm/models/list_spec.rb
62
+ - spec/smartfm/models/notification_spec.rb
63
+ - spec/smartfm/models/sentence_spec.rb
64
+ - spec/smartfm/models/user_spec.rb
65
+ - spec/smartfm/rest_clients
66
+ - spec/smartfm/rest_clients/base_spec.rb
67
+ - spec/smartfm/rest_clients/item_spec.rb
68
+ - spec/smartfm/rest_clients/like_spec.rb
69
+ - spec/smartfm/rest_clients/list_spec.rb
70
+ - spec/smartfm/rest_clients/notification_spec.rb
71
+ - spec/smartfm/rest_clients/sentence_spec.rb
72
+ - spec/smartfm/rest_clients/user_spec.rb
73
73
  - spec/spec_helper.rb
74
74
  - lib/ext
75
75
  - lib/ext/hash.rb