Class: Courier::AudiencesClient
- Inherits:
-
Object
- Object
- Courier::AudiencesClient
- 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:) ⇒ AudiencesClient 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:) ⇒ AudiencesClient
17 18 19 20 |
# File 'lib/trycourier/audiences/client.rb', line 17 def initialize(request_client:) # @type [RequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
13 14 15 |
# File 'lib/trycourier/audiences/client.rb', line 13 def request_client @request_client end |
Instance Method Details
#delete(audience_id:, request_options: nil) ⇒ Void
Deletes the specified audience.
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/trycourier/audiences/client.rb', line 70 def delete(audience_id:, request_options: nil) @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 |
#get(audience_id:, request_options: nil) ⇒ Audiences::Audience
Returns the specified audience by id.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/trycourier/audiences/client.rb', line 27 def get(audience_id:, request_options: nil) 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 |
#list_audiences(cursor: nil, request_options: nil) ⇒ Audiences::AudienceListResponse
Get the audiences associated with the authorization token.
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/trycourier/audiences/client.rb', line 105 def list_audiences(cursor: nil, request_options: nil) 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 |
#list_members(audience_id:, cursor: nil, request_options: nil) ⇒ Audiences::AudienceMemberListResponse
Get list of members of an audience.
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/trycourier/audiences/client.rb', line 87 def list_members(audience_id:, cursor: nil, request_options: nil) 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 |
#update(audience_id:, name: nil, description: nil, filter: nil, request_options: nil) ⇒ Audiences::AudienceUpdateResponse
Creates or updates audience.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/trycourier/audiences/client.rb', line 47 def update(audience_id:, name: nil, description: nil, filter: nil, request_options: nil) 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 |