kinja 0.0.2 → 0.0.3

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c945e7865c586660797f7e146653271a984ba68e
4
- data.tar.gz: 61ab343e0f22ea70bd660ce326e96ec237ec22e7
3
+ metadata.gz: 057f239f0cd267f18fa1d60f5c108e9cd9afc149
4
+ data.tar.gz: 108216b677ee7d38ea5ce22f3eb29b247f534664
5
5
  SHA512:
6
- metadata.gz: 50fd40bf8df6ca652d2da26e76e332154ab45e93cff80a91b3fd1819349bffa27c5591bb69183ece9378ebc00b092819a7a23a5dc0aa277ae824d07d9fb216bf
7
- data.tar.gz: 6f60288b336db7ee1a96721f6a12323a09d82ce4e26358a0a631c52cff79e195e23a6648dac4d13cda0fb940665cf505bda475dbe43cb7f88da8058df79b3123
6
+ metadata.gz: 3c57ede722891ad71806d525fbb5871d2876b0f2754afea5585f4f768a20dfcd5e20f0701f65b4748fefcbc0684d2f46ed3e54a92b383ef4e674aaeb98680e62
7
+ data.tar.gz: 8794fa0c27f7e80b90740d216034e1358120d1ceda56c76c91756253cead13ddbe5046a3173fe834ca64273ab35783860c966c81ac93e8a8457e2f3050f554dc
data/README.md CHANGED
@@ -43,6 +43,11 @@ post = client.get_post("http://gawker.com/lapd-claims-the-jinx-had-nothing-to-do
43
43
  post = client.get_post("1691730232")
44
44
  ```
45
45
 
46
+ ## Todo
47
+ * Refactor: Shouldn't need to log in to fetch a post
48
+ * Find API endpoint to update a post
49
+ * Build out other common REST endpoints
50
+
46
51
  ## Contributing
47
52
 
48
53
  1. Fork it ( https://github.com/adampash/kinja/fork )
data/lib/kinja/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kinja
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/kinja.rb CHANGED
@@ -7,7 +7,7 @@ module Kinja
7
7
  LOGIN_PATH = "/profile/account/burner/login"
8
8
  TOKEN_PATH = "/profile/token"
9
9
  CREATE_POST_PATH = "/core/post/add"
10
- GET_POST_PATH = "/core/post"
10
+ POST_PATH = "/core/post"
11
11
  AUTHOR_PATH = "/profile/user/views/asAuthor"
12
12
 
13
13
  def initialize(opts={})
@@ -31,9 +31,18 @@ module Kinja
31
31
  headers: { 'Content-Type' => 'application/json' }
32
32
  end
33
33
 
34
+ def update_post(link_or_id, options)
35
+ id = get_post_id link_or_id
36
+ get_api_token(login)
37
+ options[:defaultBlogId] = get_default_blog_id(@user)
38
+ HTTParty.post "#{API_ROOT}#{POST_PATH}/#{id}/update?token=#{@api_token}",
39
+ body: options.to_json,
40
+ headers: { 'Content-Type' => 'application/json' }
41
+ end
42
+
34
43
  def get_post(link_or_id)
35
44
  id = get_post_id link_or_id
36
- HTTParty.get "#{API_ROOT}#{GET_POST_PATH}/#{id}"
45
+ HTTParty.get "#{API_ROOT}#{POST_PATH}/#{id}"
37
46
  end
38
47
 
39
48
  def get_post_id(link)
@@ -42,17 +51,6 @@ module Kinja
42
51
  old_link_re = /\.com\/(\d+)\//
43
52
  return link.match(new_link_re)[1] if link.match(new_link_re)
44
53
  return link.match(old_link_re)[1] if link.match(old_link_re)
45
- # isLink: (link) ->
46
- # @newLink(link) or @oldLink(link)
47
- # newLink: (link) ->
48
- # link.match(/-(\d+)\/?/)
49
- # oldLink: (link) ->
50
- # link.match(/\.com\/\d+\//)
51
- # postId: (link) ->
52
- # if @newLink(link)
53
- # link.match(/-(\d+)\/?/)[1]
54
- # else
55
- # link.match(/\.com\/(\d+)\//)[1]
56
54
  end
57
55
 
58
56
  def get_author(user)
@@ -0,0 +1,251 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://kinja.com/api/profile/account/burner/login?screenName=gemtest&token=mzjjk%20judly%20bjysk%20ujnbv
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Access-Control-Allow-Headers:
16
+ - Content-Type
17
+ Access-Control-Allow-Methods:
18
+ - POST, GET, OPTIONS, PUT, DELETE
19
+ Access-Control-Allow-Origin:
20
+ - "*"
21
+ Cache-Control:
22
+ - no-cache, no-store, private
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ P3p:
26
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
27
+ Set-Cookie:
28
+ - KinjaBurner="d41d8cd98f00b204e9800998ecf8427e|mzjjk judly bjysk ujnbv"; Expires=Thu,
29
+ 13 Mar 2025 20:24:38 GMT; Path=/; HTTPOnly
30
+ - KinjaRememberMe=5876237249235511023|1822a5ef-743d-452a-815a-8b4a35bafc1e;
31
+ Expires=Thu, 13 Mar 2025 20:24:38 GMT; Path=/; HTTPOnly
32
+ - KinjaSession=1822a5ef-743d-452a-815a-8b4a35bafc1e; Expires=Mon, 23 Mar 2015
33
+ 20:24:38 GMT; Path=/; HTTPOnly
34
+ - geocc=US;path=/;
35
+ X-Kinja:
36
+ - 'app11.xyz.kinja-ops.com #1069'
37
+ X-Kinja-Version:
38
+ - '20141118'
39
+ X-Robots-Tag:
40
+ - noindex
41
+ Content-Length:
42
+ - '352'
43
+ Accept-Ranges:
44
+ - none
45
+ Date:
46
+ - Mon, 16 Mar 2015 20:24:38 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ Age:
50
+ - '0'
51
+ Connection:
52
+ - keep-alive
53
+ X-Served-By:
54
+ - cache-jfk1030-JFK
55
+ X-Cache:
56
+ - MISS
57
+ X-Cache-Hits:
58
+ - '0'
59
+ X-Timer:
60
+ - S1426537478.084367,VS0,VE53
61
+ Vary:
62
+ - X-Feature-Hash
63
+ body:
64
+ encoding: UTF-8
65
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","authType":4,"authName":"burner","createdMillis":1424733492000,"updatedMillis":1426537478130,"lastLoginMillis":1426537478130,"status":"enabled","avatar":{"id":"17jcxk0ml1k8qpng","format":"png"},"superUser":false,"remoteAccounts":[]}}'
66
+ http_version:
67
+ recorded_at: Mon, 16 Mar 2015 20:24:37 GMT
68
+ - request:
69
+ method: get
70
+ uri: http://kinja.com/api/profile/token
71
+ body:
72
+ encoding: US-ASCII
73
+ string: ''
74
+ headers:
75
+ Cookie:
76
+ - KinjaSession=1822a5ef-743d-452a-815a-8b4a35bafc1e
77
+ response:
78
+ status:
79
+ code: 200
80
+ message: OK
81
+ headers:
82
+ Access-Control-Allow-Headers:
83
+ - Content-Type
84
+ Access-Control-Allow-Methods:
85
+ - POST, GET, OPTIONS, PUT, DELETE
86
+ Access-Control-Allow-Origin:
87
+ - "*"
88
+ Cache-Control:
89
+ - no-cache, no-store, private
90
+ Content-Type:
91
+ - application/json; charset=utf-8
92
+ P3p:
93
+ - CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
94
+ Set-Cookie:
95
+ - KinjaSession=1822a5ef-743d-452a-815a-8b4a35bafc1e; Expires=Mon, 23 Mar 2015
96
+ 20:24:38 GMT; Path=/; HTTPOnly
97
+ - geocc=US;path=/;
98
+ X-Kinja:
99
+ - 'app04.bfc.kinja-ops.com #1069'
100
+ X-Kinja-Version:
101
+ - '20141118'
102
+ X-Robots-Tag:
103
+ - noindex
104
+ Content-Length:
105
+ - '172'
106
+ Accept-Ranges:
107
+ - none
108
+ Date:
109
+ - Mon, 16 Mar 2015 20:24:38 GMT
110
+ Via:
111
+ - 1.1 varnish
112
+ Connection:
113
+ - keep-alive
114
+ X-Served-By:
115
+ - cache-jfk1033-JFK
116
+ X-Cache:
117
+ - MISS
118
+ X-Cache-Hits:
119
+ - '0'
120
+ X-Timer:
121
+ - S1426537478.184876,VS0,VE6
122
+ Vary:
123
+ - X-Feature-Hash
124
+ body:
125
+ encoding: UTF-8
126
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"token":"21df3dc7-d016-482f-9f71-8cd0a0e06b0b","session":"1822a5ef-743d-452a-815a-8b4a35bafc1e","createdMillis":1426537478187}}'
127
+ http_version:
128
+ recorded_at: Mon, 16 Mar 2015 20:24:37 GMT
129
+ - request:
130
+ method: get
131
+ uri: http://kinja.com/api/profile/user/views/asAuthor?ids=5876237249235511023
132
+ body:
133
+ encoding: US-ASCII
134
+ string: ''
135
+ headers: {}
136
+ response:
137
+ status:
138
+ code: 200
139
+ message: OK
140
+ headers:
141
+ Access-Control-Allow-Headers:
142
+ - Content-Type
143
+ Access-Control-Allow-Methods:
144
+ - POST, GET, OPTIONS, PUT, DELETE
145
+ Access-Control-Allow-Origin:
146
+ - "*"
147
+ Content-Type:
148
+ - application/json; charset=utf-8
149
+ X-Kinja:
150
+ - 'app18.xyz.kinja-ops.com #1069'
151
+ X-Kinja-Version:
152
+ - '20141118'
153
+ X-Robots-Tag:
154
+ - noindex
155
+ X-Cdn-Fetch:
156
+ - mantle-origin-cache
157
+ Content-Length:
158
+ - '217'
159
+ Accept-Ranges:
160
+ - none
161
+ Date:
162
+ - Mon, 16 Mar 2015 20:24:38 GMT
163
+ Via:
164
+ - 1.1 varnish
165
+ Age:
166
+ - '10'
167
+ Connection:
168
+ - keep-alive
169
+ X-Served-By:
170
+ - cache-jfk1024-JFK
171
+ X-Cache:
172
+ - HIT
173
+ X-Cache-Hits:
174
+ - '1'
175
+ X-Timer:
176
+ - S1426537478.235141,VS0,VE0
177
+ Vary:
178
+ - X-Feature-Hash
179
+ Set-Cookie:
180
+ - geocc=US;path=/;
181
+ body:
182
+ encoding: UTF-8
183
+ string: '{"meta":{"error":null,"warnings":[]},"data":[{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","superUser":false,"defaultBlogId":1634457255,"avatar":{"id":"17jcxk0ml1k8qpng","format":"png"}}]}'
184
+ http_version:
185
+ recorded_at: Mon, 16 Mar 2015 20:24:37 GMT
186
+ - request:
187
+ method: post
188
+ uri: http://kinja.com/api/core/post/1687581385/update?token=21df3dc7-d016-482f-9f71-8cd0a0e06b0b
189
+ body:
190
+ encoding: UTF-8
191
+ string: '{"publishTimeMillis":1426537477797,"defaultBlogId":1634457255}'
192
+ headers:
193
+ Content-Type:
194
+ - application/json
195
+ response:
196
+ status:
197
+ code: 200
198
+ message: OK
199
+ headers:
200
+ Access-Control-Allow-Origin:
201
+ - "*"
202
+ Access-Control-Allow-Headers:
203
+ - Content-Type
204
+ Access-Control-Allow-Methods:
205
+ - POST, GET, OPTIONS, PUT, DELETE
206
+ Content-Type:
207
+ - application/json; charset=utf-8
208
+ X-Kinja:
209
+ - 'app03.bfc.kinja-ops.com #6039'
210
+ X-Cdn-Fetch:
211
+ - mantle-default
212
+ Content-Length:
213
+ - '2832'
214
+ Accept-Ranges:
215
+ - none
216
+ Date:
217
+ - Mon, 16 Mar 2015 20:24:38 GMT
218
+ Via:
219
+ - 1.1 varnish
220
+ Connection:
221
+ - keep-alive
222
+ X-Served-By:
223
+ - cache-jfk1034-JFK
224
+ X-Cache:
225
+ - MISS
226
+ X-Cache-Hits:
227
+ - '0'
228
+ X-Timer:
229
+ - S1426537478.297798,VS0,VE75
230
+ Vary:
231
+ - X-Feature-Hash
232
+ Set-Cookie:
233
+ - geocc=US;path=/;
234
+ body:
235
+ encoding: UTF-8
236
+ string: '{"meta":{"error":null,"warnings":[]},"data":{"id":1687581385,"parentId":null,"parentAuthorId":null,"starterId":1687581385,"publishTimeMillis":1426537477797,"lastUpdateTimeMillis":1426537478357,"timezone":"America/New_York","shareBlogId":null,"sharedPostId":null,"sharedUrl":null,"salesAvatar":null,"sponsored":false,"status":"PUBLISHED","authorId":"5876237249235511023","allowReplies":true,"byline":"","showByline":true,"properties":"","xmliId":null,"blogId":[1634457255],"defaultBlogId":1634457255,"authorBlogId":1634457255,"liveBlog":false,"approved":true,"headline":"","original":"<p>[<a
237
+ data-attr=\"http://gawker.com/no-playlist-1685415865\" href=\"http://gawker.com/no-playlist-1685415865\">Gawker</a>]</p>","source":"wysiwyg","images":[],"videos":[],"videoThumbs":[],"author":{"id":"5876237249235511023","screenName":"gemtest","displayName":"gemtest","defaultBlogId":1634457255,"defaultBlog":null,"avatar":{"id":"17jcxk0ml1k8qpng","format":"png"}},"tags":[],"blogs":[{"id":1634457255,"name":"gemtest","displayName":"gemtest","canonicalHost":"gemtest.kinja.com","hosts":[],"status":"ENABLED","timezone":"America/New_York","timezoneOffset":-14400000,"timezoneShortname":"EDT","mergedProperties":null,"avatar":null}],"annotation":null,"viewstats":null,"promotions":[],"replyMeta":null,"replyCount":null,"parent":null,"starter":null,"blogPostAction":null,"score":null,"insets":[],"referencedBy":[],"likes":null,"sharedPost":null,"reframes":[],"noindex":null,"isRecommended":null,"permalink":"http://gemtest.kinja.com/gawker-1687581385","permalinkHost":"http://gemtest.kinja.com","permalinkPath":"/gawker-1687581385","display":"<p
238
+ class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
239
+ target=\"_blank\">Gawker</a><inset id=\"1685415865\"></inset>]</p><!-- core-decorated
240
+ -->","excerpt":"<p class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
241
+ target=\"_blank\">Gawker</a>]</p>","compact":"[Gawker]...","plaintext":"[Gawker]","shortHeadline":"","shortExcerpt":"<p
242
+ class=\"first-text\">[<a href=\"http://gawker.com/no-playlist-1685415865\"
243
+ target=\"_blank\">Gawker</a>]</p>","excerptWithAssets":"<p class=\"first-text\">[<a
244
+ href=\"http://gawker.com/no-playlist-1685415865\" target=\"_blank\">Gawker</a>\n
245
+ <inset id=\"1685415865\"></inset>]</p>","aboveHeadline":null,"leftOfHeadline":null,"firstAsset":"","length":8,"postId":1687581385,"isBlip":true,"sharingMainImage":null,"facebookImage":null,"decorationFlags":["Default"],"publishTime":{"timestamp":1426537477797,"timezone":"America/New_York","MdyHm":"03/16/2015
246
+ 16:24","MdyatHm":"03/16/2015 at 16:24","rfc822":"Mon, 16 Mar 2015 20:24:37
247
+ GMT","yMdHmsZ":"2015-03-16T16:24:37-04:00","hmma":"4:24pm","day":"Monday","Mddyyhmma":"3/16/15
248
+ 4:24pm","fullDate":"March 16, 2015","relative":{"amount":null,"type":"now"}},"authorBlogName":"gemtest"}}'
249
+ http_version:
250
+ recorded_at: Mon, 16 Mar 2015 20:24:38 GMT
251
+ recorded_with: VCR 2.9.3
@@ -65,6 +65,13 @@ describe Kinja do
65
65
  end
66
66
  end
67
67
 
68
+ it "updates posts" do
69
+ VCR.use_cassette('update-post') do
70
+ link = "http://gemtest.kinja.com/gawker-1687581385"
71
+ post = kinja.update_post(link, publishTimeMillis: DateTime.now.strftime('%Q').to_i)
72
+ end
73
+ end
74
+
68
75
  it "retrieves posts" do
69
76
  VCR.use_cassette('get_post') do
70
77
  post = kinja.get_post("1691726561")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Pash
@@ -157,6 +157,7 @@ files:
157
157
  - spec/fixtures/vcr_cassettes/author-path-er.yml
158
158
  - spec/fixtures/vcr_cassettes/get_post.yml
159
159
  - spec/fixtures/vcr_cassettes/login.yml
160
+ - spec/fixtures/vcr_cassettes/update-post.yml
160
161
  - spec/fixtures/vcr_cassettes/write-post.yml
161
162
  - spec/lib/kinja_spec.rb
162
163
  homepage: ''
@@ -188,5 +189,6 @@ test_files:
188
189
  - spec/fixtures/vcr_cassettes/author-path-er.yml
189
190
  - spec/fixtures/vcr_cassettes/get_post.yml
190
191
  - spec/fixtures/vcr_cassettes/login.yml
192
+ - spec/fixtures/vcr_cassettes/update-post.yml
191
193
  - spec/fixtures/vcr_cassettes/write-post.yml
192
194
  - spec/lib/kinja_spec.rb