Skip to content

Commit

Permalink
Merge pull request #9 from eversign/expand-api
Browse files Browse the repository at this point in the history
Expand api
  • Loading branch information
alexkhalevine authored Apr 27, 2021
2 parents 115bf78 + 19737d7 commit 54e75c9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'dotenv/load'
require 'eversign'
require_relative '../lib/eversign-sdk'
require 'configurations'

module Config
Expand Down
33 changes: 33 additions & 0 deletions lib/eversign-sdk.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'eversign/version'
require 'configurations'
require 'addressable/uri'
require_relative 'eversign/client'
require_relative 'eversign/models/business'
require_relative 'eversign/models/file'
require_relative 'eversign/models/field'
require_relative 'eversign/models/signer'
require_relative 'eversign/models/recipient'
require_relative 'eversign/models/document'
require_relative 'eversign/models/template'
require_relative 'eversign/models/error'
require_relative 'eversign/models/exception'
require_relative 'eversign/mappings/business'
require_relative 'eversign/mappings/file'
require_relative 'eversign/mappings/document'
require_relative 'eversign/mappings/exception'

module Eversign
include Configurations
configurable String, :access_key
configurable Integer, :business_id
configurable String, :oauth_base
configurable String, :api_base do |value|
value ||= 'https://api.eversign.com'
parsed = Addressable::URI.parse(value)
if %w(http https).include?(parsed.scheme)
value
else
raise ArgumentError 'Invalid API Base URL'
end
end
end
10 changes: 10 additions & 0 deletions lib/eversign/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ def send_reminder_for_document(document_hash, signer_id)

private

def append_sdk_id (body)
unless body.nil?
bodyHash = JSON.parse(body)
bodyHash['client'] = 'ruby-sdk'
return bodyHash.to_json
end
end

def execute_request(method, path, body = nil, multipart = false)
@faraday ||= Faraday.new(base_uri) do |conn|
conn.headers = {}
Expand All @@ -163,6 +171,8 @@ def execute_request(method, path, body = nil, multipart = false)
conn.adapter :net_http
end

body = append_sdk_id(body)

@faraday.send(method) do |request|
request.url path
request.body = body if body
Expand Down
2 changes: 1 addition & 1 deletion lib/eversign/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Eversign
VERSION = '1.0.0'
VERSION = '1.0.1'
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
SimpleCov.start

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'eversign'
require 'eversign-sdk'


0 comments on commit 54e75c9

Please sign in to comment.