/
client.rb
46 lines (38 loc) · 956 Bytes
/
client.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Onepost
class Client
include Onepost::Provider
include Onepost::Authorization
include Onepost::AuthorizedPage
include Onepost::Post
include Onepost::SocialPost
include Onepost::Webhook
include Onepost::Event
RAPID_API_HOST = "onepost1.p.rapidapi.com"
TIMEOUT = 180
JSON_CONTENT_TYPE = "application/json"
attr_accessor :rapid_api_key, :secret_key
def initialize(data={})
self.rapid_api_key = data.fetch(:rapid_api_key)
self.secret_key = data.fetch(:secret_key)
end
private
def default_query
{
"secret_key" => secret_key
}
end
def default_body
{}
end
def default_headers
{
"Content-Type" => JSON_CONTENT_TYPE,
"x-rapidapi-key" => rapid_api_key,
"x-rapidapi-host" => RAPID_API_HOST
}
end
def construct_url(endpoint)
"https://#{RAPID_API_HOST}/#{endpoint}"
end
end
end