Class: Trycourier::Resources::Tenants

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/tenants.rb,
lib/trycourier/resources/tenants/templates.rb,
lib/trycourier/resources/tenants/preferences.rb,
lib/trycourier/resources/tenants/preferences/items.rb

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:



150
151
152
153
154
# File 'lib/trycourier/resources/tenants.rb', line 150

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

Instance Attribute Details

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



7
8
9
# File 'lib/trycourier/resources/tenants.rb', line 7

def preferences
  @preferences
end

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



10
11
12
# File 'lib/trycourier/resources/tenants.rb', line 10

def templates
  @templates
end

Instance Method Details

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

Delete a Tenant

Parameters:

Returns:

  • (nil)

See Also:



109
110
111
112
113
114
115
116
# File 'lib/trycourier/resources/tenants.rb', line 109

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: {}) ⇒ Trycourier::Models::TenantListResponse

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

Get a List of Tenants

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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



87
88
89
90
91
92
93
94
95
96
# File 'lib/trycourier/resources/tenants.rb', line 87

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

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

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

Get Users in Tenant

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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



136
137
138
139
140
141
142
143
144
145
# File 'lib/trycourier/resources/tenants.rb', line 136

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

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

Get a Tenant

Parameters:

  • tenant_id (String)

    A unique identifier representing the tenant to be returned.

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

Returns:

See Also:



23
24
25
26
27
28
29
30
# File 'lib/trycourier/resources/tenants.rb', line 23

def retrieve(tenant_id, params = {})
  @client.request(
    method: :get,
    path: ["tenants/%1$s", tenant_id],
    model: Trycourier::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: {}) ⇒ Trycourier::Models::Tenant

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

Create or Replace a Tenant

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 (Trycourier::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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
# File 'lib/trycourier/resources/tenants.rb', line 58

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