Module: Gorillapi::RequestMethods
Instance Method Summary
collapse
#print_request, #print_results, #request_details, #show_curl_request
Instance Method Details
#build_request ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/gorillapi/request_methods.rb', line 110
def build_request
options = {
request_method: @request_method,
url: url,
path: @path,
params: @params,
content_type: content_type,
accept_header: ,
token: token,
}
RequestBuilder.new(options)
end
|
#delete(path, print_only = false, params: {}) ⇒ Object
100
101
102
103
104
105
106
107
108
|
# File 'lib/gorillapi/request_methods.rb', line 100
def delete(path, print_only = false, params: {})
@caller = caller[0][/`.*'/][1..-2].humanize.titleize
@request_method = 'DELETE'
@path = path
@params = params
builder = build_request
handle_print(builder, print_only)
end
|
#get(path, print_only = false, params: {}) ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/gorillapi/request_methods.rb', line 68
def get(path, print_only = false, params: {})
@caller = caller[0][/`.*'/][1..-2].humanize.titleize
@request_method = 'GET'
@path = path
@params = params
builder = build_request
handle_print(builder, print_only)
end
|
#handle_print(builder, print_only = false) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/gorillapi/request_methods.rb', line 58
def handle_print(builder, print_only = false)
if print_only
print_request(builder, print_only)
else
results = builder.send
print_results(builder, results)
end
end
|
#post(path, print_only = false, params: {}) ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/gorillapi/request_methods.rb', line 79
def post(path, print_only = false, params: {})
@caller = caller[0][/`.*'/][1..-2].humanize.titleize
@request_method = 'POST'
@path = path
@params = params
builder = build_request
handle_print(builder, print_only)
end
|
#put(path, print_only = false, params: {}) ⇒ Object
90
91
92
93
94
95
96
97
98
|
# File 'lib/gorillapi/request_methods.rb', line 90
def put(path, print_only = false, params: {})
@caller = caller[0][/`.*'/][1..-2].humanize.titleize
@request_method = 'PUT'
@path = path
@params = params
builder = build_request
handle_print(builder, print_only)
end
|