Class: Trycourier::Resources::Profiles

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/profiles.rb,
lib/trycourier/resources/profiles/lists.rb

Defined Under Namespace

Classes: Lists

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Profiles

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 Profiles.

Parameters:



144
145
146
147
# File 'lib/trycourier/resources/profiles.rb', line 144

def initialize(client:)
  @client = client
  @lists = Trycourier::Resources::Profiles::Lists.new(client: client)
end

Instance Attribute Details

#listsTrycourier::Resources::Profiles::Lists (readonly)



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

def lists
  @lists
end

Instance Method Details

#create(user_id, profile:, request_options: {}) ⇒ Trycourier::Models::ProfileCreateResponse

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

Merge the supplied values with an existing profile or create a new profile if one doesn’t already exist.

Parameters:

  • user_id (String)

    A unique identifier representing the user associated with the requested profile.

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

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/trycourier/resources/profiles.rb', line 26

def create(user_id, params)
  parsed, options = Trycourier::ProfileCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["profiles/%1$s", user_id],
    body: parsed,
    model: Trycourier::Models::ProfileCreateResponse,
    options: options
  )
end

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

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

Deletes the specified user profile.

Parameters:

  • user_id (String)

    A unique identifier representing the user associated with the requested user pro

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

Returns:

  • (nil)

See Also:



101
102
103
104
105
106
107
108
# File 'lib/trycourier/resources/profiles.rb', line 101

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

#replace(user_id, profile:, request_options: {}) ⇒ Trycourier::Models::ProfileReplaceResponse

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

When using ‘PUT`, be sure to include all the key-value pairs required by the recipient’s profile. Any key-value pairs that exist in the profile but fail to be included in the ‘PUT` request will be removed from the profile. Remember, a `PUT` update is a full replacement of the data. For partial updates, use the [Patch](www.courier.com/docs/reference/profiles/patch/) request.

Parameters:

  • user_id (String)

    A unique identifier representing the user associated with the requested user pro

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

Returns:

See Also:



130
131
132
133
134
135
136
137
138
139
# File 'lib/trycourier/resources/profiles.rb', line 130

def replace(user_id, params)
  parsed, options = Trycourier::ProfileReplaceParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["profiles/%1$s", user_id],
    body: parsed,
    model: Trycourier::Models::ProfileReplaceResponse,
    options: options
  )
end

#retrieve(user_id, request_options: {}) ⇒ Trycourier::Models::ProfileRetrieveResponse

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

Returns the specified user profile.

Parameters:

  • user_id (String)

    A unique identifier representing the user associated with the requested profile.

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

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/trycourier/resources/profiles.rb', line 51

def retrieve(user_id, params = {})
  @client.request(
    method: :get,
    path: ["profiles/%1$s", user_id],
    model: Trycourier::Models::ProfileRetrieveResponse,
    options: params[:request_options]
  )
end

#update(user_id, patch:, request_options: {}) ⇒ nil

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

Update a profile

Parameters:

Returns:

  • (nil)

See Also:



76
77
78
79
80
81
82
83
84
85
# File 'lib/trycourier/resources/profiles.rb', line 76

def update(user_id, params)
  parsed, options = Trycourier::ProfileUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["profiles/%1$s", user_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end