Class: Courier::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["COURIER_API_KEY"], base_url: ENV["COURIER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/courier/client.rb', line 101
def initialize(
api_key: ENV["COURIER_API_KEY"],
base_url: ENV["COURIER_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://api.courier.com"
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"COURIER_API_KEY\"")
end
@api_key = api_key.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay
)
@send_ = Courier::Resources::Send.new(client: self)
@audiences = Courier::Resources::Audiences.new(client: self)
@providers = Courier::Resources::Providers.new(client: self)
@audit_events = Courier::Resources::AuditEvents.new(client: self)
@auth = Courier::Resources::Auth.new(client: self)
@automations = Courier::Resources::Automations.new(client: self)
@journeys = Courier::Resources::Journeys.new(client: self)
@brands = Courier::Resources::Brands.new(client: self)
@bulk = Courier::Resources::Bulk.new(client: self)
@inbound = Courier::Resources::Inbound.new(client: self)
@lists = Courier::Resources::Lists.new(client: self)
@messages = Courier::Resources::Messages.new(client: self)
@requests = Courier::Resources::Requests.new(client: self)
@notifications = Courier::Resources::Notifications.new(client: self)
@routing_strategies = Courier::Resources::RoutingStrategies.new(client: self)
@profiles = Courier::Resources::Profiles.new(client: self)
@tenants = Courier::Resources::Tenants.new(client: self)
@translations = Courier::Resources::Translations.new(client: self)
@users = Courier::Resources::Users.new(client: self)
end
|
Instance Attribute Details
#api_key ⇒ String
19
20
21
|
# File 'lib/courier/client.rb', line 19
def api_key
@api_key
end
|
25
26
27
|
# File 'lib/courier/client.rb', line 25
def audiences
@audiences
end
|
31
32
33
|
# File 'lib/courier/client.rb', line 31
def audit_events
@audit_events
end
|
34
35
36
|
# File 'lib/courier/client.rb', line 34
def auth
@auth
end
|
37
38
39
|
# File 'lib/courier/client.rb', line 37
def automations
@automations
end
|
43
44
45
|
# File 'lib/courier/client.rb', line 43
def brands
@brands
end
|
46
47
48
|
# File 'lib/courier/client.rb', line 46
def bulk
@bulk
end
|
49
50
51
|
# File 'lib/courier/client.rb', line 49
def inbound
@inbound
end
|
40
41
42
|
# File 'lib/courier/client.rb', line 40
def journeys
@journeys
end
|
52
53
54
|
# File 'lib/courier/client.rb', line 52
def lists
@lists
end
|
55
56
57
|
# File 'lib/courier/client.rb', line 55
def messages
@messages
end
|
61
62
63
|
# File 'lib/courier/client.rb', line 61
def notifications
@notifications
end
|
67
68
69
|
# File 'lib/courier/client.rb', line 67
def profiles
@profiles
end
|
28
29
30
|
# File 'lib/courier/client.rb', line 28
def providers
@providers
end
|
58
59
60
|
# File 'lib/courier/client.rb', line 58
def requests
@requests
end
|
64
65
66
|
# File 'lib/courier/client.rb', line 64
def routing_strategies
@routing_strategies
end
|
22
23
24
|
# File 'lib/courier/client.rb', line 22
def send_
@send_
end
|
70
71
72
|
# File 'lib/courier/client.rb', line 70
def tenants
@tenants
end
|
73
74
75
|
# File 'lib/courier/client.rb', line 73
def translations
@translations
end
|
76
77
78
|
# File 'lib/courier/client.rb', line 76
def users
@users
end
|