Class: VitableConnect::Members::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/VitableConnect/members/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/VitableConnect/members/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#get(request_options: {}, **params) ⇒ VitableConnect::Types::MemberResponse

Retrieves a member's profile by ID — identity, demographics, address, contact details, tobacco status, and profile status. Access is scoped to the authenticated principal; a member not visible to the caller returns a 404.

Examples:

client.members.get(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/VitableConnect/members/client.rb', line 31

def get(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::MemberResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_household(request_options: {}, **params) ⇒ VitableConnect::Types::HouseholdMembersResponse

Lists a member's household as a per-participant table — the account holder plus each active household member, with name, relationship, member type, date of birth, and household-admin flag. Access is scoped to the authenticated principal; a member not visible to the caller (or with no household) returns a 404.

Examples:

client.members.get_household(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/VitableConnect/members/client.rb', line 218

def get_household(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/household",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::HouseholdMembersResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list(request_options: {}, **params) ⇒ VitableConnect::Types::MemberListResponse

Retrieves a paginated list of the members in the authenticated organization's book — identity, contact details, and address. The book covers members reached through an employer in the organization's book as well as members of a group it owns. Supports free-text search (name, email, phone number, or exact member id).

Examples:

client.members.list(
  limit: 20,
  page: 1
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :limit (Integer, nil)
  • :page (Integer, nil)
  • :search (String, nil)
  • :vitable_organization (String, nil)

Returns:



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/VitableConnect/members/client.rb', line 383

def list(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["search"] = params[:search] if params.key?(:search)

  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  VitableConnect::Internal::OffsetItemIterator.new(
    initial_page: query_params["page"],
    item_field: :data,
    has_next_field: nil,
    step: false
  ) do |next_page|
    query_params["page"] = next_page
    request = VitableConnect::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "GET",
      path: "v2/members",
      headers: headers,
      query: query_params,
      request_options: request_options
    )
    begin
      response = @client.send(request)
    rescue Net::HTTPRequestTimeout
      raise VitableConnect::Errors::TimeoutError
    end
    code = response.code.to_i
    if code.between?(200, 299)
      parsed_response = VitableConnect::Types::MemberListResponse.load(response.body)
      [parsed_response, response]
    else
      error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
      raise error_class.new(response.body, code: code)
    end
  end
end

#list_dependents(request_options: {}, **params) ⇒ VitableConnect::Types::MemberDependentsResponse

Lists a member's active legal dependents — name, relationship, date of birth, age, and sex at birth. Access is scoped to the authenticated principal; a member not visible to the caller returns a 404.

Examples:

client.members.list_dependents(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/VitableConnect/members/client.rb', line 74

def list_dependents(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/dependents",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::MemberDependentsResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_employments(request_options: {}, **params) ⇒ VitableConnect::Types::MemberEmploymentsResponse

Lists a member's employment across every employer — the same employee record shape as the employer's employees list, plus the employer name. For an organization caller the rows are scoped to companies in that organization's book; a member (self/household) or Vitable Admin sees all employments. A member not visible to the caller returns a 404.

Examples:

client.members.list_employments(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/VitableConnect/members/client.rb', line 119

def list_employments(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/employments",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::MemberEmploymentsResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_enrollments(request_options: {}, **params) ⇒ VitableConnect::Types::MemberEnrollmentsResponse

Lists a member's benefit enrollments across every employer — benefit type and product, employer, carrier, plan, tier, employee deduction, employer contribution and total premium, the individual enrollment coverage boundary (coverage_end), the separate pre-effective cancellation boundary (cancelled_date), and the distinct benefit plan-year boundary (plan_year_coverage_end) used to determine whether the plan year itself has ended, the date the enrollment record was created (issued_date, the value Ops labels Issued on, reported for every row whatever the member answered), the window the member could answer in -- which never opens before the enrollment was issued, so a row issued mid-open-enrollment starts its window on its issue date -- whether a qualifying life event would currently be required for reissue under the product/open-enrollment rule, enrollment/open-enrollment window, and two statuses: election_status (what the member answered) and policy_status (what became of their coverage, null unless they enrolled). Every row includes a stable enrollment ID and the exact employer and benefit plan-year IDs used to fetch that row's plan-year detail. The full list is returned across all states so the client derives active plans (effective and upcoming) and the enrollment history from those per-row statuses. For an organization caller the rows are scoped to companies in that organization's book; a member (self/household) or Vitable Admin sees all enrollments. A member not visible to the caller returns a 404.

Examples:

client.members.list_enrollments(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/VitableConnect/members/client.rb', line 174

def list_enrollments(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/enrollments",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::MemberEnrollmentsResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_id_cards(request_options: {}, **params) ⇒ VitableConnect::Types::MemberDigitalBenefitCardsResponse

Lists a member's benefit ID cards — card type (medical, dental, vision, or rx), employer, plan, provider network, claims payer, carrier contact details, and the disclaimers printed on the card. Medical, dental and vision cards come from the member's active digital benefit cards; the rx card from the member's Ventegra pharmacy benefit (omitted when the member has no free-medication coverage), which carries no plan, network, or carrier details. Access is scoped to the authenticated principal, and an organization caller sees only cards from employers in its book; a member not visible to the caller returns a 404.

Examples:

client.members.list_id_cards(member_id: "mbr_abc123def456")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/VitableConnect/members/client.rb', line 265

def list_id_cards(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  request = VitableConnect::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/id-cards",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise VitableConnect::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    VitableConnect::Types::MemberDigitalBenefitCardsResponse.load(response.body)
  else
    error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_qualifying_life_events(request_options: {}, **params) ⇒ VitableConnect::Types::MemberQualifyingLifeEventListResponse

Lists a member's qualifying life events, including events already used for another enrollment. Returns all statuses by default; pass the status query param to filter to one (e.g. approved). Events are ordered newest submission first with stable paging. Custom text is present only when submitted and is otherwise null. A member not visible to the caller returns a 404. API keys and unbound access tokens have organization-wide access. Employer-bound tokens require employment at the bound employer, and employee-bound tokens require the exact employee-member relationship. Organization or scope mismatches return a 404 before pagination is validated.

Examples:

client.members.list_qualifying_life_events(
  member_id: "mbr_abc123def456",
  limit: 20,
  page: 1
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/VitableConnect/members/client.rb', line 319

def list_qualifying_life_events(request_options: {}, **params)
  params = VitableConnect::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["status"] = params[:status] if params.key?(:status)

  headers = {}
  headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization]

  VitableConnect::Internal::OffsetItemIterator.new(
    initial_page: query_params["page"],
    item_field: :data,
    has_next_field: nil,
    step: false
  ) do |next_page|
    query_params["page"] = next_page
    request = VitableConnect::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "GET",
      path: "v1/members/#{URI.encode_uri_component(params[:member_id].to_s)}/qualifying-life-events",
      headers: headers,
      query: query_params,
      request_options: request_options
    )
    begin
      response = @client.send(request)
    rescue Net::HTTPRequestTimeout
      raise VitableConnect::Errors::TimeoutError
    end
    code = response.code.to_i
    if code.between?(200, 299)
      parsed_response = VitableConnect::Types::MemberQualifyingLifeEventListResponse.load(response.body)
      [parsed_response, response]
    else
      error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code)
      raise error_class.new(response.body, code: code)
    end
  end
end