Class: Clicksign::Client
- Inherits:
-
Object
- Object
- Clicksign::Client
- Defined in:
- lib/clicksign/client.rb
Constant Summary collapse
- HEADERS =
{ 'Content-Type' => 'application/vnd.api+json', 'Accept' => 'application/vnd.api+json', }.freeze
Instance Method Summary collapse
- #delete(path, body: nil) ⇒ Object
- #get(path, params: {}) ⇒ Object
-
#initialize(api_key:, base_url:, open_timeout: 2, read_timeout: 10, write_timeout: 10, max_retries: 0) ⇒ Client
constructor
A new instance of Client.
- #patch(path, body:) ⇒ Object
- #post(path, body:) ⇒ Object
Constructor Details
#initialize(api_key:, base_url:, open_timeout: 2, read_timeout: 10, write_timeout: 10, max_retries: 0) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 |
# File 'lib/clicksign/client.rb', line 14 def initialize(api_key:, base_url:, open_timeout: 2, read_timeout: 10, write_timeout: 10, max_retries: 0) @api_key = api_key @base_url = base_url @open_timeout = open_timeout @read_timeout = read_timeout @write_timeout = write_timeout @max_retries = max_retries end |
Instance Method Details
#delete(path, body: nil) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/clicksign/client.rb', line 43 def delete(path, body: nil) uri = build_uri(path) request = Net::HTTP::Delete.new(uri, headers) request.body = body.to_json if body execute_with_retry(request, uri) end |
#get(path, params: {}) ⇒ Object
24 25 26 27 |
# File 'lib/clicksign/client.rb', line 24 def get(path, params: {}) uri = build_uri(path, params) execute_with_retry(Net::HTTP::Get.new(uri, headers), uri) end |
#patch(path, body:) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/clicksign/client.rb', line 36 def patch(path, body:) uri = build_uri(path) request = Net::HTTP::Patch.new(uri, headers) request.body = body.to_json execute_with_retry(request, uri) end |
#post(path, body:) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/clicksign/client.rb', line 29 def post(path, body:) uri = build_uri(path) request = Net::HTTP::Post.new(uri, headers) request.body = body.to_json execute_with_retry(request, uri) end |