Sha256: 6a5b64a9764647c497198c8cac31ef2f6e17a0cf7cb59fc11e656e59de2c94a1

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

require "faraday"
require "json"
require "logger"
require 'faraday_middleware'

module Incognia
  class Api
    # business layer: uses the Client to build domain objects
    # raises missing parameters errors
    attr_accessor :connection

    def initialize(client_id:, client_secret:)
      @connection = Client.new(client_id: client_id,
                               client_secret: client_secret,
                               host: "https://api.incognia.com/api")
    end

    def register_signup(installation_id:, address: )
      response = connection.request(
        :post,
        'v2/onboarding/signups',
        installation_id: installation_id,
        **address.to_hash
      )

      SignupAssessment.from_hash(response.body) if response.success?
    end

    def get_signup_assessment(signup_id:)
      response = connection.request(
        :get,
        "v2/onboarding/signups/#{signup_id}"
      )

      SignupAssessment.from_hash(response.body) if response.success?
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
incognia_api-0.1.0 lib/incognia/api.rb