onepost 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +2 -0
- data/lib/onepost/client.rb +3 -2
- data/lib/onepost/post.rb +5 -1
- data/lib/onepost/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5ffd7446734ce24cf0c973f0f6c7d969f021fd5277a77ccb68a8bd93eb8bd4
|
4
|
+
data.tar.gz: e0c461a70c672f63ff4cfbc6916431fc8da622095400604761410fa0a1531005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d1d19c54a62cfc365abecb59a5af501d0577aadc5c07a328ea4bf533c24cd6a131fa9a1da6b5b4a86e21e69503d3479768ee882056de73348e1778f854577a
|
7
|
+
data.tar.gz: a48bae9fdb5d9f85c6aec50c14022f0f7007f6288eb294c35b4a0f87711083ac60c4d333ba411981567b6e9489a4062fbdb22044e14e7fc7c75dca9353c95345
|
data/README.md
CHANGED
@@ -124,6 +124,8 @@ client.create_post(body: {
|
|
124
124
|
|
125
125
|
Posts are created in a "draft" state and can be updated until it is published. Notice that a `SocialPost` record is automatically created for the AuthorizedPage you provided. As you alter the `authorized_page_ids`, these `SocialPost` records will be automatically created or destroyed for each page you are posting to.
|
126
126
|
|
127
|
+
(*Note:* Do you need to upload your image? View the test case in [this commit](https://github.com/akdarrah/onepost-gem/commit/3b4ee062d68141404e09843293e16f313a46dc18) as an example of how to do that.)
|
128
|
+
|
127
129
|
Additionally, you can use the `publish_at` field to specify a time for OnePost to automatically publish the post. Since we didn't schedule this post to be published automatically, let's publish it using the API:
|
128
130
|
|
129
131
|
```ruby
|
data/lib/onepost/client.rb
CHANGED
@@ -10,6 +10,7 @@ module Onepost
|
|
10
10
|
|
11
11
|
RAPID_API_HOST = "onepost1.p.rapidapi.com"
|
12
12
|
TIMEOUT = 180
|
13
|
+
JSON_CONTENT_TYPE = "application/json"
|
13
14
|
|
14
15
|
attr_accessor :rapid_api_key, :secret_key
|
15
16
|
|
@@ -32,9 +33,9 @@ module Onepost
|
|
32
33
|
|
33
34
|
def default_headers
|
34
35
|
{
|
35
|
-
"Content-Type" =>
|
36
|
+
"Content-Type" => JSON_CONTENT_TYPE,
|
36
37
|
"x-rapidapi-key" => rapid_api_key,
|
37
|
-
"x-rapidapi-host" =>
|
38
|
+
"x-rapidapi-host" => RAPID_API_HOST
|
38
39
|
}
|
39
40
|
end
|
40
41
|
|
data/lib/onepost/post.rb
CHANGED
@@ -41,9 +41,13 @@ module Onepost
|
|
41
41
|
body = default_body.merge(options.fetch(:body, {}))
|
42
42
|
headers = default_headers.merge(options.fetch(:headers, {}))
|
43
43
|
|
44
|
+
if headers["Content-Type"] == Onepost::Client::JSON_CONTENT_TYPE
|
45
|
+
body = body.to_json
|
46
|
+
end
|
47
|
+
|
44
48
|
response = HTTParty.post(url, {
|
45
49
|
query: query,
|
46
|
-
body: body
|
50
|
+
body: body,
|
47
51
|
headers: headers,
|
48
52
|
timeout: Onepost::Client::TIMEOUT
|
49
53
|
})
|
data/lib/onepost/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onepost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Darrah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|