Class: Walinko::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/walinko.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, **opts) ⇒ Client

Returns a new instance of Client.

Parameters:

  • api_key (String)

    required, e.g. “walk_live_<keyId>.<secret>”

  • base_url (String)

    optional, defaults to “api.walinko.com

  • timeout (Integer)

    read timeout in seconds (default 30)

  • open_timeout (Integer)

    connection timeout in seconds (default 10)

  • max_retries (Integer)

    retries on idempotent failures (default 2)

  • logger (#info, #warn, #error)

    optional structured logger



32
33
34
35
36
# File 'lib/walinko.rb', line 32

def initialize(api_key:, **opts)
  @config = Configuration.new(api_key: api_key, **opts)
  @http   = HttpClient.new(@config)
  @messages = Messages.new(@http)
end

Instance Attribute Details

#configWalinko::Configuration (readonly)



21
22
23
# File 'lib/walinko.rb', line 21

def config
  @config
end

#messagesWalinko::Messages (readonly)

Returns:



24
25
26
# File 'lib/walinko.rb', line 24

def messages
  @messages
end

Instance Method Details

#last_rate_limitWalinko::RateLimitSnapshot?

Snapshot of the rate-limit window from the most recent response. Returns ‘nil` until the first call has completed.

Returns:



41
42
43
# File 'lib/walinko.rb', line 41

def last_rate_limit
  @http.last_rate_limit
end

#last_request_idString?

The ‘X-Request-Id` from the most recent response (or `nil`). Useful when filing support tickets.

Returns:

  • (String, nil)


48
49
50
# File 'lib/walinko.rb', line 48

def last_request_id
  @http.last_request_id
end