dandemeyere/responsys-api — pull request #22 by florrain (2014-12-03 23:31:11+00:00)
Title: Major changes (ResponseObject, edited response hash)

@12and1studio as usual :ship:
@evantahler another pull request you're welcome to review && comment ! Also maybe you would have other methods to add in the `ResponseObject` ?

:warning: This is a major change will be part of the next major release, probably v1.0.0.

# Hash is trash
Because our code often repeats the same basic operations on the hash, we'd like to make it more simple. So instead of using the response as a hash, this would force all our users to handle the response as a dev-friendly object. Yes it is.

## Examples
### Before

```ruby
def handle_errors(response)
raise "Responsys error - #{response[:error][:code]} - #{response[:error][:message]}" if response.is_a?(Hash) && response.has_key?(:status) && response[:status] == "failure"
response
end
```

### After
```ruby
def embrace_this_new_handle_errors(response)
raise "Responsys error - #{response.error_desc}" if response.error?
response
end
```

Methods on the `ResponseObject` thay may be interesting:
- `success?`
- `error?`
- `error_code`
- `error_message`
- `error_desc`

- `data`
- `response_hash`

# Response hash
Also because it was the best occasion to do it, previously the response hash was:
```json
{ status: "success", data: [{ EMAIL_PERMISSION_STATUS_: "I" }] }
```

But because it makes more sense, the status is now a boolean:
```json
{ success: true, data: [{ EMAIL_PERMISSION_STATUS_: "I" }] }
```

# Helpers
Are a little refactored.