Class: Courier::AsyncAudiencesClient
- Inherits:
-
Object
- Object
- Courier::AsyncAudiencesClient
- Defined in:
- lib/trycourier/audiences/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#delete(audience_id:, request_options: nil) ⇒ Void
Deletes the specified audience.
-
#get(audience_id:, request_options: nil) ⇒ Audiences::Audience
Returns the specified audience by id.
- #initialize(request_client:) ⇒ AsyncAudiencesClient constructor
-
#list_audiences(cursor: nil, request_options: nil) ⇒ Audiences::AudienceListResponse
Get the audiences associated with the authorization token.
-
#list_members(audience_id:, cursor: nil, request_options: nil) ⇒ Audiences::AudienceMemberListResponse
Get list of members of an audience.
-
#update(audience_id:, name: nil, description: nil, filter: nil, request_options: nil) ⇒ Audiences::AudienceUpdateResponse
Creates or updates audience.
Constructor Details
#initialize(request_client:) ⇒ AsyncAudiencesClient
124 125 126 127 |
# File 'lib/trycourier/audiences/client.rb', line 124 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
120 121 122 |
# File 'lib/trycourier/audiences/client.rb', line 120 def request_client @request_client end |
Instance Method Details
#delete(audience_id:, request_options: nil) ⇒ Void
Deletes the specified audience.
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/trycourier/audiences/client.rb', line 181 def delete(audience_id:, request_options: nil) Async do @request_client.conn.delete("/audiences/#{audience_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end end end |
#get(audience_id:, request_options: nil) ⇒ Audiences::Audience
Returns the specified audience by id.
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/trycourier/audiences/client.rb', line 134 def get(audience_id:, request_options: nil) Async do response = @request_client.conn.get("/audiences/#{audience_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end Audiences::Audience.from_json(json_object: response.body) end end |
#list_audiences(cursor: nil, request_options: nil) ⇒ Audiences::AudienceListResponse
Get the audiences associated with the authorization token.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/trycourier/audiences/client.rb', line 220 def list_audiences(cursor: nil, request_options: nil) Async do response = @request_client.conn.get("/audiences") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "cursor": cursor }.compact end Audiences::AudienceListResponse.from_json(json_object: response.body) end end |
#list_members(audience_id:, cursor: nil, request_options: nil) ⇒ Audiences::AudienceMemberListResponse
Get list of members of an audience.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/trycourier/audiences/client.rb', line 200 def list_members(audience_id:, cursor: nil, request_options: nil) Async do response = @request_client.conn.get("/audiences/#{audience_id}/members") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "cursor": cursor }.compact end Audiences::AudienceMemberListResponse.from_json(json_object: response.body) end end |
#update(audience_id:, name: nil, description: nil, filter: nil, request_options: nil) ⇒ Audiences::AudienceUpdateResponse
Creates or updates audience.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/trycourier/audiences/client.rb', line 156 def update(audience_id:, name: nil, description: nil, filter: nil, request_options: nil) Async do response = @request_client.conn.put("/audiences/#{audience_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), name: name, description: description, filter: filter }.compact end Audiences::AudienceUpdateResponse.from_json(json_object: response.body) end end |