Sha256: 2f18f02d4b8410ba294afe51fe94df5a98ee24f12c3b6fec86cb98ebfd52b71f

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

module Plaid
  module Client

    class ThinClient
      attr_accessor :institution, :endpoint, :secret, :access_token, :email, :client_id

      require 'plaid/client/configuration'
      require 'plaid/client/followup'
      require 'plaid/client/entity'
      require 'plaid/client/balance'
      require 'plaid/client/body'
      require 'plaid/plaid_object'
      require 'plaid/plaid_error'
      require 'plaid/plaid_response'
      require 'httparty'
      include Plaid::Client::Configurations
      include Plaid::Client::Bodies
      include Plaid::Client::Entities
      include Plaid::Client::Balances
      include Plaid::Client::Followups
      include HTTParty

      base_uri endpoint
      format :json
      ssl_ca_file certpath
      ssl_version :SSLv3
      debug_output $stdout

      def initialize(e_mail, institution, access_token)
        self.email = e_mail
        self.institution = institution
        self.access_token = access_token
      end

      #for testing through IRB
      def secrets(client_id, secret)
        self.client_id = client_id
        self.secret = secret
        "Set"
      end

      def settings
        puts "Base URI: " + endpoint.to_s
        puts "Cert: " + certpath.to_s
        puts "Email: " + self.email.to_s
        puts "Plaid Client_id: " + self.client_id.to_s
        puts "Webhook address: " + webhook_address
        puts "Save full response: " + save_full_response.to_s
      end

      #generic method for handling the structure of the response. Only creates an error object if there is an error (business error) from Plaid.com. Yields to the block with calling function
      def handle(response)
        if response.code.eql? 200
          yield(response)
        else
          PlaidError.new(response, "Error")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plaid-kilt-0.5.5 lib/plaid/client/thin_client.rb
plaid-kilt-0.5.4 lib/plaid/client/thin_client.rb