Skip to content
Merged
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
4 changes: 2 additions & 2 deletions help_scout.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require 'help_scout/version'
Gem::Specification.new do |spec|
spec.name = "help_scout"
spec.version = HelpScout::VERSION
spec.authors = ["Dennis Paagman", "Miriam Tocino", "Mark Mulder"]
spec.email = ["[email protected]", "[email protected]", "[email protected]"]
spec.authors = ["Dennis Paagman", "Miriam Tocino", "Mark Mulder", "Martin Balk"]
spec.email = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"]

spec.summary = "HelpScout is an API client for Help Scout"
spec.homepage = "https://github.com/Springest/help_scout"
Expand Down
2 changes: 1 addition & 1 deletion lib/help_scout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def request(method, path, options)
when HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT
@last_response.parsed_response
when HTTP_BAD_REQUEST
raise ValidationError, last_response.parsed_response["message"]
raise ValidationError, last_response.parsed_response["validationErrors"]
when HTTP_FORBIDDEN
raise ForbiddenError
when HTTP_NOT_FOUND
Expand Down
15 changes: 12 additions & 3 deletions spec/helpscout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

context 'with invalid input' do
it 'returns validation errors' do
data = { subject: "Help me!", customer: { email: "" } }
data = { subject: "Help me!", customer: { email: "[email protected]" } }

url = 'https://api.helpscout.net/v1/conversations.json'
stub_request(:post, url).
Expand All @@ -30,10 +30,19 @@
headers: {
'Content-Type' => 'application/json'
},
body: { error: "Input could not be validated", message: "Email is not valid" }.to_json
body: {
"error" => "Input could not be validated",
"validationErrors" => [
{
"property" => "customer:email",
"value" => "[email protected]",
"message" => "Email is not valid"
}
]
}.to_json
)

expect { client.create_conversation(data) }.to raise_error(HelpScout::ValidationError, "Email is not valid")
expect { client.create_conversation(data) }.to raise_error(HelpScout::ValidationError, '[{"property"=>"customer:email", "value"=>"[email protected]", "message"=>"Email is not valid"}]')
end
end

Expand Down