Class: StubHubApi::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/stub_hub_api/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(token:, sandbox:) ⇒ Base
Returns a new instance of Base.
5
6
7
8
|
# File 'lib/stub_hub_api/base.rb', line 5
def initialize(token:, sandbox:)
@token = token
@sandbox = sandbox
end
|
Instance Attribute Details
#sandbox ⇒ Object
Returns the value of attribute sandbox.
3
4
5
|
# File 'lib/stub_hub_api/base.rb', line 3
def sandbox
@sandbox
end
|
#token ⇒ Object
Returns the value of attribute token.
3
4
5
|
# File 'lib/stub_hub_api/base.rb', line 3
def token
@token
end
|
Instance Method Details
#delete_query_api(url) ⇒ Object
45
46
47
|
# File 'lib/stub_hub_api/base.rb', line 45
def delete_query_api url
session.delete(make_request_url(url, {})).body
end
|
#get_query_api(url, options) ⇒ Object
10
11
12
|
# File 'lib/stub_hub_api/base.rb', line 10
def get_query_api url, options
session.get(make_request_url(url, options)).body
end
|
#post_multi_part_query_api(url, options, file) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/stub_hub_api/base.rb', line 35
def post_multi_part_query_api url, options, file
session.post do |req|
req.url make_request_url(url, options)
req.['Content-Type'] = 'multipart/form-data'
req.body = {}
req.body[:file] = Faraday::UploadIO.new(file, 'application/pdf', "#{Time.now.to_i * rand(1000)}.pdf")
req.options.timeout = 2000
end.body
end
|
#post_multi_pdfs_json_query_api(url, body) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/stub_hub_api/base.rb', line 26
def post_multi_pdfs_json_query_api url, body
session.post do |req|
req.url url
req.["Content-Type"] = 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
req.body = body
req.options.timeout = 2000
end.body
end
|
#post_query_api(url, payload = false, options) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/stub_hub_api/base.rb', line 14
def post_query_api url, payload = false, options
if payload
session.post do |req|
req.url url
req.['Content-Type'] = 'application/json'
req.body = options.to_json
end.body
else
session.post(url, builder_options(options)).body
end
end
|
#put_query_api(url, payload = false, options) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/stub_hub_api/base.rb', line 49
def put_query_api url, payload = false, options
if payload
session.put do |req|
req.url url
req.['Content-Type'] = 'application/json'
req.body = options.to_json
end.body
else
session.put(url, builder_options(options)).body
end
end
|