Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for querying customers and updating their emails #19

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.4

Layout:
DotPosition:
Expand Down Expand Up @@ -34,3 +34,9 @@ Naming/MemoizedInstanceVariableName:

Style/Documentation:
Enabled: False

Metrics/CyclomaticComplexity:
Enabled: False

Gemspec/RequiredRubyVersion:
Enabled: False
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
### master (unreleased)

### 2.0.1 / 2020-12-15

Enhancements:

* Adds support for passing params to `list` requests (Jorge Manrubia, [#19](https://github.com/taxjar/help_scout-sdk/pull/19))
* Adds support for updating customer emails (Jorge Manrubia, [#19](https://github.com/taxjar/help_scout-sdk/pull/19))

### 2.0.0 / 2019-07-19

Breaking Changes:
Expand Down
4 changes: 2 additions & 2 deletions help_scout-sdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'activesupport'
spec.add_dependency 'faraday', '~> 0.10'
spec.add_dependency 'faraday', '>= 0.10'
spec.add_dependency 'faraday_middleware', '>= 0.10.1', '< 1.0'
spec.required_ruby_version = '>= 2.3'

Expand All @@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'byebug'
spec.add_development_dependency 'dotenv', '~> 2.2'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rake', '>= 12.3.3'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 0.70'
spec.add_development_dependency 'vcr', '~> 5.0'
Expand Down
2 changes: 1 addition & 1 deletion lib/help_scout/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def put(path, params)

private

def handle_response(result) # rubocop:disable AbcSize, Metrics/MethodLength
def handle_response(result) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
if (200...300).include? result.status
HelpScout::Response.new(result)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/help_scout/api/access_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def expired?
end

def invalid?
!!invalid # rubocop:disable Style/DoubleNegation
!!invalid
end

def invalidate!
Expand Down
6 changes: 6 additions & 0 deletions lib/help_scout/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ def initialize(params = {})

@hrefs = HelpScout::Util.map_links(params[:_links])
end

def update_email(email_id, new_email, type: :other)
email_path = "#{URI.parse(hrefs[:self]).path}/emails/#{email_id}"
HelpScout.api.put(email_path, { type: type, value: new_email })
true
end
end
end
4 changes: 2 additions & 2 deletions lib/help_scout/modules/listable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module HelpScout
module Listable
def list(id: HelpScout.default_mailbox, page: nil)
HelpScout.api.get(list_path(id), page: page).embedded_list.map { |e| new e }
def list(id: HelpScout.default_mailbox, page: nil, **params)
HelpScout.api.get(list_path(id), { page: page }.merge(params)).embedded_list.map { |e| new e }
end

def list_path(_)
Expand Down
2 changes: 1 addition & 1 deletion lib/help_scout/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HelpScout
VERSION = '2.0.0'
VERSION = '2.0.1'
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading