Class: Reverb::Api::Client
- Inherits:
-
Object
- Object
- Reverb::Api::Client
show all
- Defined in:
- lib/reverb/api/client.rb
Defined Under Namespace
Classes: HalParsingSupport
Constant Summary
collapse
{
"Content-Type" => "application/hal+json",
"Accept" => "application/hal+json"
}
Instance Method Summary
collapse
-
#add_default_header(header) ⇒ Object
-
#authenticate(email, password) ⇒ Object
-
#create_listing(param) ⇒ Object
-
#create_webhook(url:, topic:) ⇒ Object
-
#default_headers ⇒ Object
-
#delete(path, params) ⇒ Object
-
#find_draft(sku) ⇒ Object
-
#find_listing_by_sku(sku) ⇒ Object
-
#get(path, params = {}) ⇒ Object
-
#initialize(reverb_token: nil, oauth_token: nil, url: "https://reverb.com", basic_auth: nil, headers: {}, api_version: nil) ⇒ Client
constructor
url: Base URL of the Reverb API (e.g.: reverb.com) basic_auth: optional basic auth for hitting Reverb Sandbox URLs.
-
#post(path, params) ⇒ Object
-
#put(path, params) ⇒ Object
-
#webhooks ⇒ Object
Constructor Details
#initialize(reverb_token: nil, oauth_token: nil, url: "https://reverb.com", basic_auth: nil, headers: {}, api_version: nil) ⇒ Client
url: Base URL of the Reverb API (e.g.: reverb.com) basic_auth: optional basic auth for hitting Reverb Sandbox URLs
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/reverb/api/client.rb', line 15
def initialize(reverb_token: nil,
oauth_token: nil,
url: "https://reverb.com",
basic_auth: nil,
headers:{},
api_version: nil)
@reverb_token = reverb_token
@oauth_token = oauth_token
@reverb_url = url
@basic_auth = basic_auth
@api_version = api_version
.merge!()
end
|
Instance Method Details
33
34
35
|
# File 'lib/reverb/api/client.rb', line 33
def ()
.merge!()
end
|
#authenticate(email, password) ⇒ Object
37
38
39
|
# File 'lib/reverb/api/client.rb', line 37
def authenticate(email, password)
post("/api/auth/email", email: email, password: password)
end
|
#create_listing(param) ⇒ Object
41
42
43
|
# File 'lib/reverb/api/client.rb', line 41
def create_listing(param)
post("/api/listings", param)
end
|
#create_webhook(url:, topic:) ⇒ Object
53
54
55
|
# File 'lib/reverb/api/client.rb', line 53
def create_webhook(url:, topic:)
post("/api/webhooks/registrations", url: url, topic: topic)
end
|
29
30
31
|
# File 'lib/reverb/api/client.rb', line 29
def
@_headers ||= HEADERS.dup
end
|
#delete(path, params) ⇒ Object
73
74
75
|
# File 'lib/reverb/api/client.rb', line 73
def delete(path, params)
handle_response HTTParty.delete(url(path), with_defaults(params))
end
|
#find_draft(sku) ⇒ Object
49
50
51
|
# File 'lib/reverb/api/client.rb', line 49
def find_draft(sku)
find_by_sku(sku, "draft")
end
|
#find_listing_by_sku(sku) ⇒ Object
45
46
47
|
# File 'lib/reverb/api/client.rb', line 45
def find_listing_by_sku(sku)
find_by_sku(sku, "all")
end
|
#get(path, params = {}) ⇒ Object
65
66
67
|
# File 'lib/reverb/api/client.rb', line 65
def get(path, params={})
handle_response HTTParty.get(url(path), with_defaults(params))
end
|
#post(path, params) ⇒ Object
61
62
63
|
# File 'lib/reverb/api/client.rb', line 61
def post(path, params)
handle_response HTTParty.post(url(path), with_defaults(params))
end
|
#put(path, params) ⇒ Object
69
70
71
|
# File 'lib/reverb/api/client.rb', line 69
def put(path, params)
handle_response HTTParty.put(url(path), with_defaults(params))
end
|
#webhooks ⇒ Object
57
58
59
|
# File 'lib/reverb/api/client.rb', line 57
def webhooks
get("/api/webhooks/registrations")
end
|