Class: Courier::Resources::Tenants

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/tenants.rb,
lib/courier/resources/tenants/templates.rb,
lib/courier/resources/tenants/preferences.rb,
lib/courier/resources/tenants/preferences/items.rb,
lib/courier/resources/tenants/templates/versions.rb,
sig/courier/resources/tenants.rbs,
sig/courier/resources/tenants/templates.rbs,
sig/courier/resources/tenants/preferences.rbs,
sig/courier/resources/tenants/preferences/items.rbs,
sig/courier/resources/tenants/templates/versions.rbs

Overview

Manage tenants — the organizations, teams, or accounts your users belong to — along with their users and default preferences.

Defined Under Namespace

Classes: Preferences, Templates

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tenants

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tenants.

Parameters:



161
162
163
164
165
# File 'lib/courier/resources/tenants.rb', line 161

def initialize(client:)
  @client = client
  @preferences = Courier::Resources::Tenants::Preferences.new(client: client)
  @templates = Courier::Resources::Tenants::Templates.new(client: client)
end

Instance Attribute Details

#preferencesCourier::Resources::Tenants::Preferences (readonly)



9
10
11
# File 'lib/courier/resources/tenants.rb', line 9

def preferences
  @preferences
end

#templatesCourier::Resources::Tenants::Templates (readonly)

Manage the templates and template versions scoped to a single tenant, including the ones authored in the embedded designer.



14
15
16
# File 'lib/courier/resources/tenants.rb', line 14

def templates
  @templates
end

Instance Method Details

#delete(tenant_id, request_options: {}) ⇒ nil

Deletes a tenant. Its members' workspace-level profiles and preferences live outside the tenant and are managed separately.

Parameters:

  • tenant_id (String)

    Id of the tenant to be deleted.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



118
119
120
121
122
123
124
125
# File 'lib/courier/resources/tenants.rb', line 118

def delete(tenant_id, params = {})
  @client.request(
    method: :delete,
    path: ["tenants/%1$s", tenant_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(cursor: nil, limit: nil, parent_tenant_id: nil, request_options: {}) ⇒ Courier::Models::TenantListResponse

Some parameter documentations has been truncated, see Models::TenantListParams for more details.

Lists the workspace's tenants, each carrying a name, parent tenant, properties, and default preferences. Paged.

Parameters:

  • cursor (String, nil)

    Continue the pagination with the next cursor

  • limit (Integer, nil)

    The number of tenants to return

  • parent_tenant_id (String, nil)

    Filter the list of tenants by parent_id

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/courier/resources/tenants.rb', line 94

def list(params = {})
  parsed, options = Courier::TenantListParams.dump_request(params)
  query = Courier::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "tenants",
    query: query,
    model: Courier::Models::TenantListResponse,
    options: options
  )
end

#list_users(tenant_id, cursor: nil, limit: nil, request_options: {}) ⇒ Courier::Models::TenantListUsersResponse

Some parameter documentations has been truncated, see Models::TenantListUsersParams for more details.

Returns the users belonging to a tenant with cursor paging. Use it to see who a tenant-scoped send will reach.

Parameters:

  • tenant_id (String)

    Id of the tenant for user membership.

  • cursor (String, nil)

    Continue the pagination with the next cursor

  • limit (Integer, nil)

    The number of accounts to return

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/courier/resources/tenants.rb', line 146

def list_users(tenant_id, params = {})
  parsed, options = Courier::TenantListUsersParams.dump_request(params)
  query = Courier::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["tenants/%1$s/users", tenant_id],
    query: query,
    model: Courier::Models::TenantListUsersResponse,
    options: options
  )
end

#retrieve(tenant_id, request_options: {}) ⇒ Courier::Models::Tenant

Returns one tenant with its name, parent tenant id, default preferences, properties, and the user profile applied to its members.

Parameters:

  • tenant_id (String)

    A unique identifier representing the tenant to be returned.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



28
29
30
31
32
33
34
35
# File 'lib/courier/resources/tenants.rb', line 28

def retrieve(tenant_id, params = {})
  @client.request(
    method: :get,
    path: ["tenants/%1$s", tenant_id],
    model: Courier::Tenant,
    options: params[:request_options]
  )
end

#update(tenant_id, name:, brand_id: nil, default_preferences: nil, parent_tenant_id: nil, properties: nil, user_profile: nil, request_options: {}) ⇒ Courier::Models::Tenant

Some parameter documentations has been truncated, see Models::TenantUpdateParams for more details.

Creates or replaces a tenant from a name, parent, brand, properties, and default preferences supplied in the request body.

Parameters:

  • tenant_id (String)

    A unique identifier representing the tenant to be returned.

  • name (String)

    Name of the tenant.

  • brand_id (String, nil)

    Brand to be used for the account when one is not specified by the send call.

  • default_preferences (Courier::Models::DefaultPreferences, nil)

    Defines the preferences used for the tenant when the user hasn't specified their

  • parent_tenant_id (String, nil)

    Tenant's parent id (if any).

  • properties (Hash{Symbol=>Object}, nil)

    Arbitrary properties accessible to a template.

  • user_profile (Hash{Symbol=>Object}, nil)

    A user profile object merged with user profile on send.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



64
65
66
67
68
69
70
71
72
73
# File 'lib/courier/resources/tenants.rb', line 64

def update(tenant_id, params)
  parsed, options = Courier::TenantUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["tenants/%1$s", tenant_id],
    body: parsed,
    model: Courier::Tenant,
    options: options
  )
end