latergram 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -20
- data/lib/latergram/api.rb +3 -3
- data/lib/latergram/{social_posts.rb → publications.rb} +10 -10
- data/lib/latergram/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fb1550ff17123fe9cc2cd8d74e476bc1a5c45bec8addff05a08c050ef613943
|
4
|
+
data.tar.gz: bc64f1d3fdf9288c40a8767e8232c40bb59f76852cf4403f2200bf49342811e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399657da6ce215155543436cffe99650dc62c3f45db89c8a4fbd7488c5084eabf81ce6d48c616abfc4beac37214f96809755de361c6148413db862dadf611397
|
7
|
+
data.tar.gz: be2c0f7f61d5a97ef55557e6329777fb39845cc591d1880a70513d7d758c7d7dc06e42902af7511ff4c18078a92f7a9547c1c15105c698dab2f847e26431e9c5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,12 +26,12 @@ Or install it yourself as:
|
|
26
26
|
api = Latergram::Api.new(api_key)
|
27
27
|
```
|
28
28
|
|
29
|
-
###
|
29
|
+
### Publications
|
30
30
|
|
31
|
-
#### Create a
|
31
|
+
#### Create a publication
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
api.
|
34
|
+
api.publications.create(
|
35
35
|
text: "example text",
|
36
36
|
image_urls: [url1, url2]
|
37
37
|
)
|
@@ -43,7 +43,7 @@ Response:
|
|
43
43
|
{
|
44
44
|
'data' => {
|
45
45
|
'id' => '99',
|
46
|
-
'type' => '
|
46
|
+
'type' => 'publication',
|
47
47
|
'attributes' => {
|
48
48
|
'text' => 'example text',
|
49
49
|
'created_at' => '2019-10-30T23:54:12.147+01:00',
|
@@ -55,10 +55,10 @@ Response:
|
|
55
55
|
}
|
56
56
|
```
|
57
57
|
|
58
|
-
#### Update a
|
58
|
+
#### Update a publication
|
59
59
|
|
60
60
|
```ruby
|
61
|
-
api.
|
61
|
+
api.publications.update(99, text: 'another text')
|
62
62
|
```
|
63
63
|
|
64
64
|
Response:
|
@@ -67,7 +67,7 @@ Response:
|
|
67
67
|
{
|
68
68
|
'data' => {
|
69
69
|
'id' => '99',
|
70
|
-
'type' => '
|
70
|
+
'type' => 'publication',
|
71
71
|
'attributes' => {
|
72
72
|
'text' => 'another text',
|
73
73
|
'created_at' => '2019-10-30T23:54:12.147+01:00',
|
@@ -79,10 +79,10 @@ Response:
|
|
79
79
|
}
|
80
80
|
```
|
81
81
|
|
82
|
-
#### Destroy a
|
82
|
+
#### Destroy a publication
|
83
83
|
|
84
84
|
```ruby
|
85
|
-
api.
|
85
|
+
api.publications.destroy(99)
|
86
86
|
```
|
87
87
|
|
88
88
|
Response:
|
@@ -91,7 +91,7 @@ Response:
|
|
91
91
|
{
|
92
92
|
'data' => {
|
93
93
|
'id' => '99',
|
94
|
-
'type' => '
|
94
|
+
'type' => 'publication',
|
95
95
|
'attributes' => {
|
96
96
|
'text' => 'another text',
|
97
97
|
'created_at' => '2019-10-30T23:54:12.147+01:00',
|
@@ -103,10 +103,10 @@ Response:
|
|
103
103
|
}
|
104
104
|
```
|
105
105
|
|
106
|
-
#### List all
|
106
|
+
#### List all publications
|
107
107
|
|
108
108
|
```ruby
|
109
|
-
api.
|
109
|
+
api.publications.all(page: 1, per_page: 10)
|
110
110
|
```
|
111
111
|
|
112
112
|
Response:
|
@@ -116,7 +116,7 @@ Response:
|
|
116
116
|
'data' => [
|
117
117
|
{
|
118
118
|
'id' => '98',
|
119
|
-
'type' => '
|
119
|
+
'type' => 'publication',
|
120
120
|
'attributes' => {
|
121
121
|
'text' => 'test1',
|
122
122
|
'created_at' => '2019-10-30T20:54:14.960+01:00',
|
@@ -128,7 +128,7 @@ Response:
|
|
128
128
|
# ...
|
129
129
|
{
|
130
130
|
'id' => '95',
|
131
|
-
'type' => '
|
131
|
+
'type' => 'publication',
|
132
132
|
'attributes' => {
|
133
133
|
'text' => 'test2',
|
134
134
|
'created_at' => '2019-10-29T22:46:35.857+01:00',
|
@@ -139,18 +139,18 @@ Response:
|
|
139
139
|
}
|
140
140
|
],
|
141
141
|
'links' => {
|
142
|
-
'first' => '
|
143
|
-
'last' => '
|
144
|
-
'next' => '
|
142
|
+
'first' => 'https://api.latergr.am/v1/publications?page=1&per_page=10',
|
143
|
+
'last' => 'https://api.latergr.am/v1/publications?page=26&per_page=10',
|
144
|
+
'next' => 'https://api.latergr.am/v1/publications?page=2&per_page=10'
|
145
145
|
},
|
146
146
|
'meta' => { 'total' => 51 }
|
147
147
|
}
|
148
148
|
```
|
149
149
|
|
150
|
-
#### Find one
|
150
|
+
#### Find one publication
|
151
151
|
|
152
152
|
```ruby
|
153
|
-
api.
|
153
|
+
api.publications.find(95)
|
154
154
|
```
|
155
155
|
|
156
156
|
Response:
|
@@ -159,7 +159,7 @@ Response:
|
|
159
159
|
{
|
160
160
|
'data' => {
|
161
161
|
'id' => '95',
|
162
|
-
'type' => '
|
162
|
+
'type' => 'publication',
|
163
163
|
'attributes' => {
|
164
164
|
'text' => 'test2',
|
165
165
|
'created_at' => '2019-10-29T22:46:35.857+01:00',
|
data/lib/latergram/api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'latergram/
|
3
|
+
require 'latergram/publications'
|
4
4
|
|
5
5
|
module Latergram
|
6
6
|
class Api
|
@@ -13,8 +13,8 @@ module Latergram
|
|
13
13
|
@api_url = api_url
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
@
|
16
|
+
def publications
|
17
|
+
@publications ||= Publications.new(api_key, api_url: api_url)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,10 +4,10 @@ require 'latergram/requester'
|
|
4
4
|
require 'time'
|
5
5
|
|
6
6
|
module Latergram
|
7
|
-
class
|
7
|
+
class Publications
|
8
8
|
attr_reader :api_key, :api_url
|
9
9
|
|
10
|
-
ENDPOINT = '
|
10
|
+
ENDPOINT = 'publications'
|
11
11
|
|
12
12
|
def initialize(api_key, api_url:)
|
13
13
|
@api_key = api_key
|
@@ -22,8 +22,8 @@ module Latergram
|
|
22
22
|
JSON.parse(response.body)
|
23
23
|
end
|
24
24
|
|
25
|
-
def find(
|
26
|
-
response = requester.get(ENDPOINT + "/#{
|
25
|
+
def find(publication_id)
|
26
|
+
response = requester.get(ENDPOINT + "/#{publication_id}")
|
27
27
|
|
28
28
|
raise Latergram::Error, response.body unless response.status == 200
|
29
29
|
|
@@ -33,7 +33,7 @@ module Latergram
|
|
33
33
|
def create(text:, image_urls: [])
|
34
34
|
check_images(image_urls)
|
35
35
|
|
36
|
-
parameters = {
|
36
|
+
parameters = { publication: { text: text, image_urls: image_urls }.compact }
|
37
37
|
response = requester.post(ENDPOINT, parameters)
|
38
38
|
|
39
39
|
raise Latergram::Error, response.body unless response.status == 200
|
@@ -41,17 +41,17 @@ module Latergram
|
|
41
41
|
JSON.parse(response.body)
|
42
42
|
end
|
43
43
|
|
44
|
-
def update(
|
45
|
-
parameters = {
|
46
|
-
response = requester.put(ENDPOINT + "/#{
|
44
|
+
def update(publication_id, text: nil)
|
45
|
+
parameters = { publication: { text: text }.compact }
|
46
|
+
response = requester.put(ENDPOINT + "/#{publication_id}", parameters)
|
47
47
|
|
48
48
|
raise Latergram::Error, response.body unless response.status == 200
|
49
49
|
|
50
50
|
JSON.parse(response.body)
|
51
51
|
end
|
52
52
|
|
53
|
-
def destroy(
|
54
|
-
response = requester.delete(ENDPOINT + "/#{
|
53
|
+
def destroy(publication_id)
|
54
|
+
response = requester.delete(ENDPOINT + "/#{publication_id}")
|
55
55
|
|
56
56
|
raise Latergram::Error, response.body unless response.status == 200
|
57
57
|
|
data/lib/latergram/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latergram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Krasnoperov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -156,8 +156,8 @@ files:
|
|
156
156
|
- latergram.gemspec
|
157
157
|
- lib/latergram.rb
|
158
158
|
- lib/latergram/api.rb
|
159
|
+
- lib/latergram/publications.rb
|
159
160
|
- lib/latergram/requester.rb
|
160
|
-
- lib/latergram/social_posts.rb
|
161
161
|
- lib/latergram/version.rb
|
162
162
|
homepage:
|
163
163
|
licenses:
|