Class: Braintree::BankAccountInstantVerificationGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/braintree/bank_account_instant_verification_gateway.rb

Constant Summary collapse

CREATE_JWT_MUTATION =
"mutation CreateBankAccountInstantVerificationJwt($input: CreateBankAccountInstantVerificationJwtInput!) { " +
"  createBankAccountInstantVerificationJwt(input: $input) {" +
"    jwt" +
"  }" +
"}"

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ BankAccountInstantVerificationGateway

Returns a new instance of BankAccountInstantVerificationGateway.



11
12
13
14
# File 'lib/braintree/bank_account_instant_verification_gateway.rb', line 11

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
end

Instance Method Details

#create_jwt(request) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/braintree/bank_account_instant_verification_gateway.rb', line 16

def create_jwt(request)
  variables = request.to_graphql_variables
  response = @gateway.graphql_client.query(CREATE_JWT_MUTATION, variables)
  errors = Braintree::GraphQLClient.get_validation_errors(response)

  if errors
    ErrorResult.new(@gateway, {errors: errors})
  else
    data = response.dig(:data, :createBankAccountInstantVerificationJwt)

    if data.nil?
      raise UnexpectedError, "expected :createBankAccountInstantVerificationJwt"
    end

    jwt_attrs = {
      :jwt => data[:jwt]
    }

    SuccessfulResult.new(:bank_account_instant_verification_jwt => BankAccountInstantVerificationJwt._new(jwt_attrs))
  end
end