Navigation Menu

Skip to content

Commit

Permalink
Rubocop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor Brooks committed Aug 15, 2018
1 parent 94e5232 commit ac77794
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 123 deletions.
4 changes: 2 additions & 2 deletions Rakefile
@@ -1,8 +1,8 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
version = File.exist?('VERSION') ? File.read('VERSION') : ''

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "closeio #{version}"
Expand Down
27 changes: 13 additions & 14 deletions closeio.gemspec
@@ -1,31 +1,30 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "closeio/version"
require "base64"
$:.push File.expand_path('../lib', __FILE__)
require 'closeio/version'
require 'base64'

Gem::Specification.new do |s|
s.name = "closeio"
s.name = 'closeio'
s.version = Closeio::VERSION
s.authors = ["Taylor Brooks"]
s.email = ["dGJyb29rc0BnbWFpbC5jb20="].map{ |e| Base64.decode64(e) }
s.homepage = "https://github.com/taylorbrooks/closeio"
s.summary = %q{A Ruby wrapper for the CloseIO API}
s.description = %q{A Ruby wrapper for the CloseIO API -- a sales CRM built by salespeople, for salespeople.}
s.license = "MIT"
s.authors = ['Taylor Brooks']
s.email = ['dGJyb29rc0BnbWFpbC5jb20='].map { |e| Base64.decode64(e) }
s.homepage = 'https://github.com/taylorbrooks/closeio'
s.summary = 'A Ruby wrapper for the CloseIO API'
s.description = 'A Ruby wrapper for the CloseIO API -- a sales CRM built by salespeople, for salespeople.'
s.license = 'MIT'

s.files = `git ls-files`.split($/)
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test)/})

s.require_paths = ["lib"]
s.require_paths = ['lib']

s.add_runtime_dependency 'faraday'
s.add_runtime_dependency 'faraday_middleware'
s.add_runtime_dependency 'json'

s.add_development_dependency 'bundler'
s.add_development_dependency 'rake'
s.add_development_dependency 'minitest'
s.add_development_dependency 'rake'
s.add_development_dependency 'vcr'
s.add_development_dependency 'webmock'
end
36 changes: 20 additions & 16 deletions lib/closeio/client.rb
@@ -1,9 +1,9 @@
require 'faraday'
require 'faraday_middleware'
require_relative "error"
require_relative "version"
require_relative 'error'
require_relative 'version'

Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
Dir[File.expand_path('../resources/*.rb', __FILE__)].each { |f| require f }

module Closeio
class Client
Expand Down Expand Up @@ -35,7 +35,7 @@ def initialize(api_key, logger = true, ca_file = nil, errors = false, utc_offset
@utc_offset = utc_offset
end

def get(path, options={})
def get(path, options = {})
connection.get(path, options).body
end

Expand All @@ -46,15 +46,15 @@ def post(path, req_body)
end.body
end

def put(path, options={})
def put(path, options = {})
connection.put(path, options).body
end

def delete(path, options = {})
connection.delete(path, options).body
end

def paginate(path, options={})
def paginate(path, options = {})
results = []
skip = 0

Expand All @@ -65,27 +65,31 @@ def paginate(path, options={})
skip += res['data'].count
end
end while res['has_more']
{has_more: false, total_results: res['total_results'], data: results.flatten}
{ has_more: false, total_results: res['total_results'], data: results.flatten }
end

private

def assemble_list_query(query, options)
options[:query] = if query.respond_to? :map
query.map { |k,v| "#{k}:'#{v}'" }.join(' ')
else
query
end
query.map { |k, v| "#{k}:'#{v}'" }.join(' ')
else
query
end

options
end

def connection
Faraday.new(url: "https://app.close.io/api/v1", headers: {
accept: 'application/json',
'User-Agent' => "closeio-ruby-gem/v#{Closeio::VERSION}",
'X-TZ-Offset' => utc_offset.to_s
}, ssl: { ca_file: ca_file}) do |conn|
Faraday.new(
url: 'https://app.close.io/api/v1',
headers: {
accept: 'application/json',
'User-Agent' => "closeio-ruby-gem/v#{Closeio::VERSION}",
'X-TZ-Offset' => utc_offset.to_s
},
ssl: { ca_file: ca_file }
) do |conn|
conn.basic_auth api_key, ''
conn.request :json
conn.response :logger if logger
Expand Down
2 changes: 1 addition & 1 deletion lib/closeio/error.rb
Expand Up @@ -5,7 +5,7 @@ class NotFound < Error; end
class GatewayTimeout < Error; end
end

require "faraday"
require 'faraday'
module FaradayMiddleware
class CloseioErrorHandler < Faraday::Response::Middleware
ERROR_STATUSES = 400..600
Expand Down
28 changes: 13 additions & 15 deletions lib/closeio/resources/activity.rb
@@ -1,16 +1,15 @@
module Closeio
class Client
module Activity

def list_activities(options={})
def list_activities(options = {})
get(activity_path, options)
end

#
# Note Activities
#

def list_notes(options={})
def list_notes(options = {})
get(note_path, options)
end

Expand All @@ -22,7 +21,7 @@ def create_note(options)
post(note_path, options)
end

def update_note(id, options={})
def update_note(id, options = {})
put("#{note_path}#{id}/", options)
end

Expand All @@ -34,7 +33,7 @@ def delete_note(id)
# Email Activities
#

def list_emails(options={})
def list_emails(options = {})
get(email_path, options)
end

Expand All @@ -46,7 +45,7 @@ def create_email(body)
post(email_path, body)
end

def update_email(id, options={})
def update_email(id, options = {})
put("#{email_path}#{id}/", options)
end

Expand All @@ -58,7 +57,7 @@ def delete_email(id)
# EmailThread Activities
#

def list_emailthreads(options={})
def list_emailthreads(options = {})
get(emailthread_path, options)
end

Expand All @@ -74,11 +73,11 @@ def delete_emailthread(id)
# Call Activities
#

def list_calls(options={})
def list_calls(options = {})
get(call_path, options)
end

def create_call(options={})
def create_call(options = {})
post(call_path, options)
end

Expand All @@ -89,25 +88,24 @@ def delete_call(id)
private

def activity_path
"activity/"
'activity/'
end

def note_path
"activity/note/"
'activity/note/'
end

def email_path
"activity/email/"
'activity/email/'
end

def emailthread_path
"activity/emailthread/"
'activity/emailthread/'
end

def call_path
"activity/call/"
'activity/call/'
end

end
end
end
10 changes: 4 additions & 6 deletions lib/closeio/resources/bulk_action.rb
@@ -1,20 +1,19 @@
module Closeio
class Client
module BulkAction

def list_bulk_emails
get(bulk_action_path)
end

def send_bulk_email(options={})
def send_bulk_email(options = {})
post("#{bulk_action_path}email/", options)
end

def bulk_delete(options={})
def bulk_delete(options = {})
post("#{bulk_action_path}delete/", options)
end

def bulk_edit(options={})
def bulk_edit(options = {})
# query: search query for the edit
# type:
# set_lead_status: lead_status_id
Expand All @@ -26,9 +25,8 @@ def bulk_edit(options={})
private

def bulk_action_path
"bulk_action/"
'bulk_action/'
end

end
end
end
8 changes: 3 additions & 5 deletions lib/closeio/resources/contact.rb
@@ -1,8 +1,7 @@
module Closeio
class Client
module Contact

def list_contacts(params=nil)
def list_contacts(_params = nil)
get(contact_path)
end

Expand All @@ -24,10 +23,9 @@ def delete_contact(id)

private

def contact_path(id=nil)
id ? "contact/#{id}/" : "contact/"
def contact_path(id = nil)
id ? "contact/#{id}/" : 'contact/'
end

end
end
end
8 changes: 3 additions & 5 deletions lib/closeio/resources/custom_field.rb
@@ -1,7 +1,6 @@
module Closeio
class Client
module CustomField

def list_custom_fields
get(custom_field_path)
end
Expand All @@ -10,11 +9,11 @@ def find_custom_field(id)
get("#{custom_field_path}#{id}/")
end

def create_custom_field(options={})
def create_custom_field(options = {})
post(custom_field_path, options)
end

def update_custom_field(id, options={})
def update_custom_field(id, options = {})
put("#{custom_field_path}#{id}/", options)
end

Expand All @@ -25,9 +24,8 @@ def delete_custom_field(id)
private

def custom_field_path
"custom_fields/lead/"
'custom_fields/lead/'
end

end
end
end
4 changes: 1 addition & 3 deletions lib/closeio/resources/email_account.rb
@@ -1,11 +1,9 @@
module Closeio
class Client
module EmailAccount

def list_email_accounts
get("email_account/")
get('email_account/')
end

end
end
end
7 changes: 3 additions & 4 deletions lib/closeio/resources/email_template.rb
@@ -1,7 +1,6 @@
module Closeio
class Client
module EmailTemplate

def list_email_templates(params = {}, paginate = false)
if paginate
paginate(email_template_path, params)
Expand All @@ -22,11 +21,11 @@ def render_email_templates(id, params = {}, paginate = false)
end
end

def create_email_template(id, options={})
def create_email_template(_id, options = {})
post(email_template_path, options)
end

def update_email_template(id, options={})
def update_email_template(id, options = {})
put("#{email_template_path}#{id}/", options)
end

Expand All @@ -37,7 +36,7 @@ def delete_email_template(id)
private

def email_template_path
"email_template/"
'email_template/'
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/closeio/resources/event.rb
@@ -1,11 +1,9 @@
module Closeio
class Client
module Event

def list_events(options = {})
get("event/", options)
get('event/', options)
end

end
end
end

0 comments on commit ac77794

Please sign in to comment.