Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #101 from HelloFax/New-Features
Browse files Browse the repository at this point in the history
New features
  • Loading branch information
jyoung488 committed Dec 12, 2018
2 parents 2e0c14f + efdee9a commit 97456dc
Show file tree
Hide file tree
Showing 35 changed files with 1,154 additions and 762 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ my_account = HelloSign.get_account
my_signature_requests = HelloSign.get_signature_requests

# view a specific signature request
signature_request = HelloSign.get_signature_request :signature_request_id => '42383e7327eda33f4b8b91217cbe95408cc1285f'
signature_request = HelloSign.get_signature_request signature_request_id: '42383e7327eda33f4b8b91217cbe95408cc1285f'
```

If you need to authenticate for multiple users and you want a separated client for them, you can run:
```ruby
client2 = HelloSign::Client.new :api_key => 'your_user_api_key'
client2 = HelloSign::Client.new api_key: 'your_user_api_key'
user_account = client2.get_account
```
### Specifying files
Expand Down
19 changes: 7 additions & 12 deletions lib/hello_sign.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
Expand All @@ -20,29 +19,25 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

require 'hello_sign/version'
require 'hello_sign/configuration'
require 'hello_sign/client'

module HelloSign
extend Configuration
#
# # If HelloSign module doesn't respond to method, then delegates it to HelloSign::Client
# @param method [Symbol] method name
# @param *args [Array] arguments passed into the method
# @param &block [Block] a block passed into the method
#

# If HelloSign module doesn't respond to method, then delegates it to HelloSign::Client
# @param method [Symbol] method name
# @param *args [Array] arguments passed into the method
# @param &block [Block] a block passed into the method
def self.method_missing(method, *args, &block)
return super unless client.respond_to?(method)
client.send(method, *args, &block)
end

#
# If HelloSign module don't respond to method, asks HelloSign::Client whether it responded or not
# @param method [Symbol] method name
#
# If HelloSign module doesn't respond to method, asks HelloSign::Client whether it responded or not
# @param method [Symbol] method name
def self.respond_to?(method, include_all=false)
return super || client.respond_to?(method)
end
Expand Down
3 changes: 1 addition & 2 deletions lib/hello_sign/api.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
Expand All @@ -20,7 +19,6 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

require 'hello_sign/api/account'
require 'hello_sign/api/embedded'
Expand All @@ -30,3 +28,4 @@
require 'hello_sign/api/unclaimed_draft'
require 'hello_sign/api/oauth'
require 'hello_sign/api/api_app'
require 'hello_sign/api/bulk_send_job'
47 changes: 17 additions & 30 deletions lib/hello_sign/api/account.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
Expand All @@ -20,71 +19,59 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

module HelloSign
module Api

#
# Contains all the API calls for the Account resource.
# Take a look at our API Documentation on the Account resource (https://app.hellosign.com/api/reference#Account)
# for more information about this.
#
# @author [hellosign]
#

module Account
#

# Returns the current user's account information.
#
# @return [HelloSign::Resource::Account] current user's account
# @return [HelloSign::Resource::Account] Current user's Account
#
# @example
# account = @client.get_account
#
def get_account
HelloSign::Resource::Account.new get('/account')
end

#
# Creates a new HelloSign account. The user will still need to confirm the email address
# Creates a new HelloSign account. The user will need to confirm the email address
# to complete the creation process.
#
# Note: This request does not require authentication.
#
# @option opts [String] email_address New user's email address
#
# @return [HelloSign::Resource::Account] New user's account information
# @return [HelloSign::Resource::Account] New user's Account
#
# @example
# account = @client.create_account :email_address => '[email protected]'
#
# account = @client.create_account email_address: '[email protected]'
def create_account(opts)
HelloSign::Resource::Account.new post('/account/create', :body => opts)
HelloSign::Resource::Account.new post('/account/create', body: opts)
end

# Updates the current user's Account Callback URL.
# @option opts [String] callback_url New callback URL
#
# Updates the current user's callback URL
# @option opts [String] callback_url New user's callback url
#
# @return [HelloSign::Resource::Account] Updated user's account information
# @return [HelloSign::Resource::Account] Updated Account
#
# @example
# account = @client.update_account :callback_url => 'https://www.example.com/callback'
#
# account = @client.update_account callback_url: 'https://www.example.com/callback'
def update_account(opts)
HelloSign::Resource::Account.new post('/account', :body => opts)
HelloSign::Resource::Account.new post('/account', body: opts)
end

#
# Check whether an account exists
# @option opts [String] email_address user email
# Checks whether an Account exists
# @option opts [String] email_address User's email address
#
# @return [Bool] true if exists, else false
# @example
# account = @client.verify :email_address => '[email protected]'
#
# @example
# account = @client.verify email_address: '[email protected]'
def verify(opts)
post('/account/verify', :body => opts).empty? ? false : true
post('/account/verify', body: opts).empty? ? false : true
end
end
end
Expand Down
52 changes: 27 additions & 25 deletions lib/hello_sign/api/api_app.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
Expand All @@ -20,51 +19,44 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

module HelloSign
module Api
#
# Contains all the API calls for the ApiApp resource.
# Take a look at our API Documentation for ApiApps (https://app.hellosign.com/api/reference#ApiApp)
# Take a look at our API Documentation on ApiApps (https://app.hellosign.com/api/reference#ApiApp)
# for more information about this.
#
# @author [hellosign]
#

module ApiApp

#
# Retrieves information about a specific API App by a given ID
# Retrieves an ApiApp with a given ID
# @option opts [String] client_id The Client ID of the ApiApp.
#
# @return [HelloSign::Resource::ApiApp] the ApiApp
# @return [HelloSign::Resource::ApiApp]
#
# @example
# app = @client.get_api_app :client_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967'
#
# app = @client.get_api_app client_id: 'fa5c8a0b0f492d768749333ad6fcc214c111e967'
def get_api_app(opts)
HelloSign::Resource::ApiApp.new get("/api_app/#{opts[:client_id]}")
end

#
# Returns a list of ApiApps that you currently have access to on your account
# Returns a list of ApiApps that your Account can access.
# @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional)
# @option opts [Integer] page_size Determines the number of ApiApps returned per page. Defaults to 20. (optional)
#
# @return [HelloSign::Resource::ResourceArray]
#
# @example
# apps = @client.get_api_apps :page => 1
#
# apps = @client.get_api_apps page: 1
def get_api_apps(opts={})
path = '/api_app/list'
path += opts[:page] ? "?page=#{opts[:page]}" : ''
path += opts[:page_size] ? "&page_size=#{opts[:page_size]}" : ''
HelloSign::Resource::ResourceArray.new get(path, opts), 'api_apps', HelloSign::Resource::ApiApp
end

#
# Creates a new API Application on your account
# Creates a new ApiApp on your Account
# @option opts [String] name The name assigned to the ApiApp.
# @option opts [String] domain The domain associated with the ApiApp.
# @option opts [String] callback_url The URL that will receive callback events for the ApiApp. (optional)
Expand All @@ -74,16 +66,20 @@ def get_api_apps(opts={})
# @option opts [String<Hash>] white_labeling_options Object with elements and values serialized to a string to customize the signer page, if available in the API subscription. (optional)
# @option opts [Boolean] options[can_insert_everywhere] Determines if signers can "Insert Everywhere" when signing a document. (optional)
#
# @return [HelloSign::Resource::ApiApp] newly created ApiApp object
# @return [HelloSign::Resource::ApiApp] newly created ApiApp
#
# @example
# app = @client.create_api_app :name => 'My Production App', :domain => 'example.com', :'oauth[callback_url]' => 'https://example.com/oauth', 'oauth[scopes]' => 'basic_account_info,request_signature'
# app = @client.create_api_app(
# name: 'My Production App',
# domain: 'example.com',
# 'oauth[callback_url]': 'https://example.com/oauth',
# 'oauth[scopes]': 'basic_account_info,request_signature'
# )
def create_api_app(opts)
HelloSign::Resource::ApiApp.new post('/api_app', :body => opts)
HelloSign::Resource::ApiApp.new post('/api_app', body: opts)
end

#
# Updates settings for a specific ApiApp on your account
# Updates the ApiApp settings.
# @option opts [String] client_id The Client ID of the ApiApp you want to update.
# @option opts [String] name The name assigned to the ApiApp. (optional)
# @option opts [String] domain The domain associated with the ApiApp. (optional)
Expand All @@ -97,19 +93,25 @@ def create_api_app(opts)
# @return [HelloSign::Resource::ApiApp] an ApiApp object
#
# @example
# app = @client.update_api_app :name => 'My Newly Renamed App', :domain => 'example2.com', :'oauth[callback_url]' => 'https://example2.com/oauth', 'oauth[scopes]' => 'basic_account_info,request_signature'
# app = @client.update_api_app(
# name: 'My Newly Renamed App',
# domain: 'example2.com',
# 'oauth[callback_url]': 'https://example2.com/oauth',
# 'oauth[scopes]': 'basic_account_info, request_signature'
# )
def update_api_app(opts)
id = opts.delete(:client_id)
path = '/api_app/' + id
HelloSign::Resource::ApiApp.new post(path, :body => opts)
HelloSign::Resource::ApiApp.new post(path, body: opts)
end

#
# Deletes an ApiApp. Only available for ApiApps you own.
# @option opts [String] client_id The Client ID of the ApiApp you want to delete.
#
# @return [HTTP::Status] 204 No Content
#
# @example
# result = @client.delete_api_app :client_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967'
# response = @client.delete_api_app client_id: 'fa5c8a0b0f492d768749333ad6fcc214c111e967'
def delete_api_app(opts)
path = '/api_app/' + opts[:client_id]
delete(path)
Expand Down
62 changes: 62 additions & 0 deletions lib/hello_sign/api/bulk_send_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# The MIT License (MIT)
#
# Copyright (C) 2014 hellosign.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

module HelloSign
module Api
# Contains all the API calls for the BulkSendJob resource.
# Take a look at our API Documentation on BulkSendJobs (https://app.hellosign.com/api/reference#BulkSendJob)
# for more information about this.
#
# @author [hellosign]

module BulkSendJob

# Retrieves a BulkSendJob with a given ID
# @option opts [String] bulk_send_job_id The BulkSendJob ID to retrieve.
#
# @return [HelloSign::Resource::BulkSendJob]
#
# @example
# bulk_send_job = @client.get_bulk_send_job bulk_send_job_id: 'af299494bdcad318b4856aa34aa263dbdaaee9ab'
def get_bulk_send_job(opts)
path = "/bulk_send_job/#{opts[:bulk_send_job_id]}"

HelloSign::Resource::BulkSendJob.new get(path)
end

# Returns a list of BulkSendJobs that your Account can access.
# @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional)
# @option opts [Integer] page_size Determines the number of BulkSendJobs returned per page. Defaults to 20. (optional)
#
# @return [HelloSign::Resource::ResourceArray]
#
# @example
# bulk_send_jobs = @client.get_bulk_send_jobs page: 1
def get_bulk_send_jobs(opts={})
path = '/bulk_send_job/list'
path += opts[:page] ? "?page=#{opts[:page]}" : ''
path += opts[:page_size] ? "&page_size=#{opts[:page_size]}" : ''
HelloSign::Resource::ResourceArray.new get(path, opts), 'bulk_send_jobs', HelloSign::Resource::BulkSendJob
end
end
end
end
Loading

0 comments on commit 97456dc

Please sign in to comment.