Class: Yasminaai::OtPs::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yasminaai/ot_ps/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/yasminaai/ot_ps/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#request_otp_for_issuing_policy(request_options: {}, **params) ⇒ untyped

This endpoint sends a one-time password (OTP). It should be called before issuing a policy.

Parameters:

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)

Returns:

  • (untyped)

Raises:

  • (error_class)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/yasminaai/ot_ps/client.rb', line 57

def request_otp_for_issuing_policy(request_options: {}, **params)
  params = Yasminaai::Internal::Types::Utils.normalize_keys(params)
  request = Yasminaai::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "issue-otp",
    body: Yasminaai::OtPs::Types::PostIssueOtpRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Yasminaai::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Yasminaai::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#request_otp_for_quote_verification(request_options: {}, **params) ⇒ untyped

This endpoint sends a one-time password (OTP) to the provided email and phone number for quote verification. It should be called before creating a quote request.

Parameters:

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)

Returns:

  • (untyped)

Raises:

  • (error_class)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/yasminaai/ot_ps/client.rb', line 25

def request_otp_for_quote_verification(request_options: {}, **params)
  params = Yasminaai::Internal::Types::Utils.normalize_keys(params)
  request = Yasminaai::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "quote-otp",
    body: Yasminaai::OtPs::Types::PostQuoteOtpRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Yasminaai::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Yasminaai::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end