medium_sdk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afab6a1385d13e4a793053d8f316d0b833965c00
4
- data.tar.gz: f5103cf9ef2728c0eee21fee3ebcedac80c706c5
3
+ metadata.gz: f0675d736cf6cab923b2ddd7c37c0aa6f58687c5
4
+ data.tar.gz: 9a20441f0ccce6d749675c035a51c0660ae62608
5
5
  SHA512:
6
- metadata.gz: cbc6d536ea192bdd2e1fe99dfbaaa709411b3af6363316f2c7d66c12b07724747d41cae24eb73cebcb11882d26169ea05300cd98a28a40f8ab9620c78227b830
7
- data.tar.gz: fb92b3958cb66cf4a3562c270ea72ba6f4961fcb932f9cc41b437fc327e0a9c7d7a0c8af9d4d1afc0da45c9b7dfd50f29e8f82e50fb7ef1e10b1d1ab2c88c58e
6
+ metadata.gz: 5627bff969b90c0515545d38031b3cc9f3d25ba666571afb5d82bdad1ea0f12a14df1342f702fa6d4f7b2837cea6fe36da4789910198fc5ffe46b4a7980dbe56
7
+ data.tar.gz: 0e1b014755985d02b2de2609faae66af49fe605f8a9113efa81bb97b18f811e027914b3f1e396194816128132ada045a2245e21c35694d012d716872aa11a904
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2016-08-18**: 0.0.3
4
+ 1. Add Swagger spec
5
+ - **2016-08-12**: 0.0.2
3
6
  - **2016-08-11**: 0.0.1
4
7
  1. Initial release
5
8
  1. Authorization via OAuth 2.0 and Integration Token
data/README.md CHANGED
@@ -17,8 +17,9 @@ A Ruby SDK for the [Medium.com API](https://github.com/Medium/medium-api-docs) i
17
17
 
18
18
  1. Auth via OAuth 2.0 with [automatic token refresh](https://github.com/grokify/faraday_middleware-oauth2_refresh) and [demo app](https://github.com/grokify/medium-sdk-ruby/tree/master/scripts/sinatra). This is necessary to request the `listPublications` or `uploadImage` access scopes.
19
19
  1. Auth via integration token with [demo app](https://github.com/grokify/medium-sdk-ruby/blob/master/scripts)
20
- 1. Get and Post convenience APIs
21
- 1. Raw APIs via Faraday HTTP client
20
+ 1. Get and Post convenience methods
21
+ 1. Raw HTTP methods via Faraday client useful for image upload
22
+ 1. [Swagger 2.0 spec in YAML](docs/medium-api-v1-swagger.yaml) and [JSON](docs/medium-api-v1-swagger.json)
22
23
 
23
24
  ## Installation
24
25
 
@@ -96,23 +97,41 @@ client = MediumSdk.new integration_token: token
96
97
  client.connection.token = token
97
98
  ```
98
99
 
99
- ### API Requests
100
+ ### Resource Methods
100
101
 
101
- #### Convenience Methods
102
+ See the Swagger 2.0 spec in [YAML](docs/medium-api-v1-swagger.yaml) and [JSON](docs/medium-api-v1-swagger.json) for more info.
102
103
 
103
- Convenience methods are provided which return the `data` property of the response body.
104
+ #### Users
105
+
106
+ ##### Getting the authenticated user’s details
104
107
 
105
108
  ```ruby
106
109
  # Getting the authenticated user’s details
107
110
  data = client.me
111
+ ```
112
+
113
+ #### Publications
114
+
115
+ ##### Listing the user’s publications
108
116
 
117
+ ```ruby
109
118
  # Listing the user’s publications
110
119
  data = client.user_publications # uses authorized user's userId
111
120
  data = client.user_publications 'user_id' # uses explicit userId
121
+ ```
122
+
123
+ ##### Fetching contributors for a publication
112
124
 
125
+ ```ruby
113
126
  # Fetching contributors for a publication
114
127
  data = client.publication_contributors 'publication_id'
128
+ ```
129
+
130
+ #### Posts
131
+
132
+ ##### Creating a post
115
133
 
134
+ ```ruby
116
135
  # Creating a user post
117
136
  data = client.post, {
118
137
  title: "Hard things in software development",
@@ -132,7 +151,11 @@ data = client.post, {
132
151
  publishedAt: "2016-08-12T00:00:00+00:00",
133
152
  notifyFollowers: false
134
153
  }
154
+ ```
155
+
156
+ ##### Creating a post under a publication
135
157
 
158
+ ```ruby
136
159
  # Creating a publication post using `publicationId`
137
160
  data = client.post, {
138
161
  title: "Hard things in software development",
@@ -140,13 +163,25 @@ data = client.post, {
140
163
  content: "<p>Cache invalidation</p><p>Naming things</p>",
141
164
  tags: ["development", "design"],
142
165
  publishStatus: "public",
143
- publicationId: "deadbeef"
166
+ publicationId: "b45573563f5a"
167
+ }
168
+ ```
169
+
170
+ #### Images
171
+
172
+ ##### Uploading an image
173
+
174
+ ```ruby
175
+ # Upload image
176
+ payload = {
177
+ image: Faraday::UploadIO.new('/path/to/my_image.jpg', 'image/jpeg')
144
178
  }
179
+ response = client.connection.http.post 'images', payload
145
180
  ```
146
181
 
147
- #### Raw Methods
182
+ ### Raw HTTP Client
148
183
 
149
- The SDK's Faraday client can be accessed for sending raw requests:
184
+ The SDK's Faraday client can be accessed for sending raw requests. This can be used to upload images using `Faraday::UploadIO`.
150
185
 
151
186
  ```ruby
152
187
  response = client.connection.http.get 'me'
@@ -156,6 +191,17 @@ response = client.connection.http do |req|
156
191
  end
157
192
  ```
158
193
 
194
+ See the [Faraday project](https://github.com/lostisland/faraday) for more info.
195
+
196
+ ## Swagger Spec
197
+
198
+ A Swagger 2.0 spec is included with this SDK for reference.
199
+
200
+ | Format | Validation |
201
+ |--------|------------|
202
+ | [`JSON Spec`](docs/medium-api-v1-swagger.json) | [Validate JSON](http://online.swagger.io/validator?url=https%3A%2F%2Fraw.githubusercontent.com%2Fgrokify%2Fmedium-sdk-ruby%2Fmaster%2Fdocs%2Fmedium-api-v1-swagger.json) |
203
+ | [`YAML Spec`](docs/medium-api-v1-swagger.yaml) | [Validate YAML](http://online.swagger.io/validator?url=https%3A%2F%2Fraw.githubusercontent.com%2Fgrokify%2Fmedium-sdk-ruby%2Fmaster%2Fdocs%2Fmedium-api-v1-swagger.yaml) |
204
+
159
205
  ## Demos
160
206
 
161
207
  Demos are in the `scripts` directory and use `.env` files for configuration.
@@ -195,6 +241,10 @@ Medium API Docs
195
241
 
196
242
  * https://github.com/Medium/medium-api-docs
197
243
 
244
+ ## Credits
245
+
246
+ 1. Swagger validation and YAML-to-JSON conversion by [`swagger-parser`](https://github.com/BigstickCarpet/swagger-parser).
247
+
198
248
  ## Contributing
199
249
 
200
250
  1. Fork it ( http://github.com/grokify/medium-sdk-ruby/fork )
@@ -2,7 +2,7 @@ module MediumSdk
2
2
  autoload :Client, 'medium_sdk/client'
3
3
  autoload :Connection, 'medium_sdk/connection'
4
4
 
5
- VERSION = '0.0.2'
5
+ VERSION = '0.0.3'
6
6
 
7
7
  class << self
8
8
  def new(opts = {})
@@ -57,6 +57,7 @@ module MediumSdk::Connection
57
57
 
58
58
  @http = Faraday.new(url: api_version_uri()) do |conn|
59
59
  conn.request :oauth2_refresh, @token
60
+ conn.request :multipart
60
61
  conn.request :json
61
62
  if @instance_headers.is_a? Hash
62
63
  @instance_headers.each do |k,v|
@@ -21,7 +21,8 @@ module MediumSdk::Connection
21
21
  'Accept-Charset' => 'utf-8'
22
22
  }
23
23
  @http = Faraday.new(url: @endpoint, headers: headers) do |conn|
24
- conn.request :json
24
+ conn.request :multipart
25
+ conn.request :json
25
26
  conn.response :json, content_type: 'application/json'
26
27
  conn.adapter Faraday.default_adapter
27
28
  end
@@ -2,5 +2,4 @@ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
4
  require 'test/unit'
5
- #require 'mocha/test_unit'
6
5
  require 'medium_sdk'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medium_sdk
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
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -112,20 +112,6 @@ dependencies:
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
- - !ruby/object:Gem::Dependency
116
- name: mocha
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
115
  - !ruby/object:Gem::Dependency
130
116
  name: rake
131
117
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +154,7 @@ dependencies:
168
154
  - - ">="
169
155
  - !ruby/object:Gem::Version
170
156
  version: '0'
171
- description: A Ruby SDK for the Medium.com API with OAuth 2 support
157
+ description: A Ruby SDK for the Medium.com API with OAuth 2 support and Swagger spec
172
158
  email: johncwang@gmail.com
173
159
  executables: []
174
160
  extensions: []