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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +58 -8
- data/lib/medium_sdk.rb +1 -1
- data/lib/medium_sdk/connection/auth_code.rb +1 -0
- data/lib/medium_sdk/connection/integration_token.rb +2 -1
- data/test/test_base.rb +0 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0675d736cf6cab923b2ddd7c37c0aa6f58687c5
|
4
|
+
data.tar.gz: 9a20441f0ccce6d749675c035a51c0660ae62608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5627bff969b90c0515545d38031b3cc9f3d25ba666571afb5d82bdad1ea0f12a14df1342f702fa6d4f7b2837cea6fe36da4789910198fc5ffe46b4a7980dbe56
|
7
|
+
data.tar.gz: 0e1b014755985d02b2de2609faae66af49fe605f8a9113efa81bb97b18f811e027914b3f1e396194816128132ada045a2245e21c35694d012d716872aa11a904
|
data/CHANGELOG.md
CHANGED
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
|
21
|
-
1. Raw
|
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
|
-
###
|
100
|
+
### Resource Methods
|
100
101
|
|
101
|
-
|
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
|
-
|
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: "
|
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
|
-
|
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 )
|
data/lib/medium_sdk.rb
CHANGED
@@ -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
|
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
|
data/test/test_base.rb
CHANGED
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.
|
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-
|
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: []
|