Class: Straddle::Resources::Representatives

Inherits:
Object
  • Object
show all
Defined in:
lib/straddle/resources/representatives.rb,
sig/straddle/resources/representatives.rbs

Overview

Representatives are people associated with a business account for ownership, control, or authorization purposes.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Representatives

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

Parameters:



237
238
239
# File 'lib/straddle/resources/representatives.rb', line 237

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id:, dob:, email:, first_name:, last_name:, mobile_number:, relationship:, ssn_last4:, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::RepresentativeResponse

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

Creates a representative for an account and returns the representative. Relationship fields identify primary representatives, control persons, and owners.

Parameters:

  • account_id (String) —

    Body param: ID of the account associated with the representative.

  • dob (Date) —

    Body param: Representative's date of birth in YYYY-MM-DD format.

  • email (String) —

    Body param: Representative's company email address.

  • first_name (String) —

    Body param: Representative's first name.

  • last_name (String) —

    Body param: Representative's last name.

  • mobile_number (String) —

    Body param: Representative's mobile phone number in E.164 format.

  • relationship (Straddle::Models::RepresentativeRelationship) —

    Body param

  • ssn_last4 (String) —

    Body param: Last four digits of the representative's Social Security number.

  • external_id (String, nil) —

    Body param: Your unique ID for the representative.

  • metadata (Hash{Symbol=>String}, nil) —

    Body param: Up to 20 user-defined key-value pairs.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

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

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/straddle/resources/representatives.rb', line 48

def create(params)
  parsed, options = Straddle::RepresentativeCreateParams.dump_request(params)
  header_params = {
    correlation_id: "correlation-id",
    idempotency_key: "idempotency-key",
    request_id: "request-id"
  }
  @client.request(
    method: :post,
    path: "v1/representatives",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Straddle::RepresentativeResponse,
    options: options
  )
end

#list(account_id: nil, level: nil, organization_id: nil, page_number: nil, page_size: nil, platform_id: nil, sort_by: nil, sort_order: nil, correlation_id: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::RepresentativeList

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

Returns a paginated list of representatives. Filter the list by account, organization, platform, or scope.

Parameters:

  • account_id (String) —

    Query param: Account ID used to filter the results.

  • level (Symbol, Straddle::Models::RepresentativeListParams::Level) —

    Query param: Scope of representatives to return.

  • organization_id (String) —

    Query param: Organization ID used to filter the results.

  • page_number (Integer) —

    Query param: Page number. Defaults to 1.

  • page_size (Integer) —

    Query param: Number of results per page. Defaults to 100. Maximum 1000.

  • platform_id (String) —

    Query param: Platform ID used to filter the results.

  • sort_by (String) —

    Query param: Field used to sort results. Defaults to id.

  • sort_order (Symbol, Straddle::Models::RepresentativeListParams::SortOrder) —

    Query param: Sort direction. Defaults to asc.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

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

Returns:

See Also:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/straddle/resources/representatives.rb', line 180

def list(params = {})
  query_params = %i[
    account_id
    level
    organization_id
    page_number
    page_size
    platform_id
    sort_by
    sort_order
  ]
  parsed, options = Straddle::RepresentativeListParams.dump_request(params)
  query = Straddle::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/representatives",
    query: query,
    headers:
      parsed.except(*query_params).transform_keys(
        correlation_id: "correlation-id",
        request_id: "request-id"
      ),
    model: Straddle::RepresentativeList,
    options: options
  )
end

#list_unmasked(representative_id, correlation_id: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::UnmaskedRepresentativeResponse

Returns the representative with the specified ID without masking sensitive fields. This endpoint requires an administrator role.

Parameters:

  • representative_id (String) —

    The ID of the representative.

  • correlation_id (String) —

    Optional client-generated identifier for tracing a series of related requests.

  • request_id (String) —

    Optional client-generated identifier for tracing one request.

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

Returns:

See Also:



223
224
225
226
227
228
229
230
231
232
# File 'lib/straddle/resources/representatives.rb', line 223

def list_unmasked(representative_id, params = {})
  parsed, options = Straddle::RepresentativeListUnmaskedParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/representatives/%1$s/unmask", representative_id],
    headers: parsed.transform_keys(correlation_id: "correlation-id", request_id: "request-id"),
    model: Straddle::UnmaskedRepresentativeResponse,
    options: options
  )
end

#retrieve(representative_id, correlation_id: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::RepresentativeResponse

Returns the representative with the specified ID.

Parameters:

  • representative_id (String) —

    The ID of the representative.

  • correlation_id (String) —

    Optional client-generated identifier for tracing a series of related requests.

  • request_id (String) —

    Optional client-generated identifier for tracing one request.

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

Returns:

See Also:



80
81
82
83
84
85
86
87
88
89
# File 'lib/straddle/resources/representatives.rb', line 80

def retrieve(representative_id, params = {})
  parsed, options = Straddle::RepresentativeRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/representatives/%1$s", representative_id],
    headers: parsed.transform_keys(correlation_id: "correlation-id", request_id: "request-id"),
    model: Straddle::RepresentativeResponse,
    options: options
  )
end

#update(representative_id, dob:, email:, first_name:, last_name:, mobile_number:, relationship:, ssn_last4:, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::RepresentativeResponse

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

Updates a representative's personal, contact, relationship, external ID, and metadata fields, then returns the representative.

Parameters:

  • representative_id (String) —

    Path param: The ID of the representative.

  • dob (Date) —

    Body param: Representative's date of birth in YYYY-MM-DD format.

  • email (String) —

    Body param: Representative's email address.

  • first_name (String) —

    Body param: Representative's first name.

  • last_name (String) —

    Body param: Representative's last name.

  • mobile_number (String) —

    Body param: Representative's mobile phone number in E.164 format.

  • relationship (Straddle::Models::RepresentativeRelationship) —

    Body param

  • ssn_last4 (String) —

    Body param: Last four digits of the representative's Social Security number.

  • external_id (String, nil) —

    Body param: Your unique ID for the representative.

  • metadata (Hash{Symbol=>String}, nil) —

    Body param: Up to 20 user-defined key-value pairs.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

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

Returns:

See Also:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/straddle/resources/representatives.rb', line 130

def update(representative_id, params)
  parsed, options = Straddle::RepresentativeUpdateParams.dump_request(params)
  header_params = {
    correlation_id: "correlation-id",
    idempotency_key: "idempotency-key",
    request_id: "request-id"
  }
  @client.request(
    method: :put,
    path: ["v1/representatives/%1$s", representative_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Straddle::RepresentativeResponse,
    options: options
  )
end