nov-smartfm 1.0.0 → 1.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.
- data/ChangeLog +6 -2
- data/lib/smartfm/core/version.rb +1 -1
- data/lib/smartfm/models/list.rb +5 -7
- data/lib/smartfm/models/notification.rb +1 -1
- data/lib/smartfm/modules/acts_as_likable.rb +2 -2
- data/lib/smartfm/modules/private_content.rb +1 -1
- data/lib/smartfm/modules/public_content.rb +10 -7
- data/lib/smartfm/rest_clients/base.rb +4 -4
- data/lib/smartfm/rest_clients/list.rb +1 -1
- data/lib/smartfm/rest_clients/user.rb +2 -2
- data/spec/smartfm/{model → models}/base_spec.rb +0 -0
- data/spec/smartfm/{model → models}/item_spec.rb +0 -0
- data/spec/smartfm/{model → models}/like_spec.rb +0 -0
- data/spec/smartfm/{model → models}/list_spec.rb +0 -0
- data/spec/smartfm/{model → models}/notification_spec.rb +0 -0
- data/spec/smartfm/{model → models}/sentence_spec.rb +0 -0
- data/spec/smartfm/{model → models}/user_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/base_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/item_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/like_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/list_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/notification_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/sentence_spec.rb +0 -0
- data/spec/smartfm/{rest_client → rest_clients}/user_spec.rb +0 -0
- metadata +17 -17
data/ChangeLog
CHANGED
@@ -39,9 +39,13 @@
|
|
39
39
|
|
40
40
|
== 0.3.1
|
41
41
|
|
42
|
-
* add sessions API
|
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
|
data/lib/smartfm/core/version.rb
CHANGED
data/lib/smartfm/models/list.rb
CHANGED
@@ -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, :
|
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
|
-
@
|
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
|
-
|
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
|
-
|
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
|
@@ -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
|
|
@@ -11,8 +11,8 @@ module Smartfm::PublicContent
|
|
11
11
|
self.deserialize(hash) || []
|
12
12
|
end
|
13
13
|
|
14
|
-
def find(
|
15
|
-
params[: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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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, :
|
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, :
|
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
|
-
|
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
|
-
|
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/
|
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 => '/
|
17
|
-
:unfollow! => {:path => '/
|
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
|
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.
|
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/
|
58
|
-
- spec/smartfm/
|
59
|
-
- spec/smartfm/
|
60
|
-
- spec/smartfm/
|
61
|
-
- spec/smartfm/
|
62
|
-
- spec/smartfm/
|
63
|
-
- spec/smartfm/
|
64
|
-
- spec/smartfm/
|
65
|
-
- spec/smartfm/
|
66
|
-
- spec/smartfm/
|
67
|
-
- spec/smartfm/
|
68
|
-
- spec/smartfm/
|
69
|
-
- spec/smartfm/
|
70
|
-
- spec/smartfm/
|
71
|
-
- spec/smartfm/
|
72
|
-
- spec/smartfm/
|
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
|