~tim/mailchimp3

b2fa823c3e806ea18c87a6dbfb946d40371168d9 — Tim Morgan 5 years ago faa37c4
Rename to MailChimp (with proper capital letters)
M README.md => README.md +14 -14
@@ 1,4 1,4 @@
# Mailchimp3
# MailChimp3

[![Circle CI](https://circleci.com/gh/seven1m/mailchimp3/tree/master.svg?style=svg)](https://circleci.com/gh/seven1m/mailchimp3/tree/master)



@@ 16,9 16,9 @@ gem install mailchimp3 (eventually)

    ```ruby
    # authenticate with HTTP Basic:
    api = Mailchimp3.new(basic_auth_key: 'my key')
    api = MailChimp3.new(basic_auth_key: 'my key')
    # ...or authenticate with an OAuth2 access token (use the 'oauth2' gem to obtain the token)
    api = Mailchimp3.new(oauth_access_token: 'token')
    api = MailChimp3.new(oauth_access_token: 'token')
    ```

2. Call a method on the api object to build the endpoint path.


@@ 49,7 49,7 @@ gem install mailchimp3 (eventually)
```ruby
require 'mailchimp3'

api = Mailchimp3.new(basic_auth_key: 'abc123abc123abc123abc123abc123ab-us2')
api = MailChimp3.new(basic_auth_key: 'abc123abc123abc123abc123abc123ab-us2')
api.lists.post(
  name: 'Church.IO',
  email_type_option: false,


@@ 157,15 157,15 @@ The following errors may be raised by the library, depending on the API response

| HTTP Status Codes   | Error Class                                                                   |
| ------------------- | ----------------------------------------------------------------------------- |
| 400                 | `Mailchimp3::Errors::BadRequest` < `Mailchimp3::Errors::ClientError`          |
| 401                 | `Mailchimp3::Errors::Unauthorized` < `Mailchimp3::Errors::ClientError`        |
| 403                 | `Mailchimp3::Errors::Forbidden` < `Mailchimp3::Errors::ClientError`           |
| 404                 | `Mailchimp3::Errors::NotFound` < `Mailchimp3::Errors::ClientError`            |
| 405                 | `Mailchimp3::Errors::MethodNotAllowed` < `Mailchimp3::Errors::ClientError`    |
| 422                 | `Mailchimp3::Errors::UnprocessableEntity` < `Mailchimp3::Errors::ClientError` |
| other 4xx errors    | `Mailchimp3::Errors::ClientError`                                             |
| 500                 | `Mailchimp3::Errors::InternalServerError` < `Mailchimp3::Errors::ServerError` |
| other 5xx errors    | `Mailchimp3::Errors::ServerError`                                             |
| 400                 | `MailChimp3::Errors::BadRequest` < `MailChimp3::Errors::ClientError`          |
| 401                 | `MailChimp3::Errors::Unauthorized` < `MailChimp3::Errors::ClientError`        |
| 403                 | `MailChimp3::Errors::Forbidden` < `MailChimp3::Errors::ClientError`           |
| 404                 | `MailChimp3::Errors::NotFound` < `MailChimp3::Errors::ClientError`            |
| 405                 | `MailChimp3::Errors::MethodNotAllowed` < `MailChimp3::Errors::ClientError`    |
| 422                 | `MailChimp3::Errors::UnprocessableEntity` < `MailChimp3::Errors::ClientError` |
| other 4xx errors    | `MailChimp3::Errors::ClientError`                                             |
| 500                 | `MailChimp3::Errors::InternalServerError` < `MailChimp3::Errors::ServerError` |
| other 5xx errors    | `MailChimp3::Errors::ServerError`                                             |

The exception object has the following methods:



@@ 195,7 195,7 @@ The `message` should be a simple string given by the API, e.g. "Resource Not Fou
}
```

Alternatively, you may rescue `Mailchimp3::Errors::BaseError` and branch your code based on
Alternatively, you may rescue `MailChimp3::Errors::BaseError` and branch your code based on
the status code returned by calling `error.status`.

## Copyright & License

M lib/mailchimp3.rb => lib/mailchimp3.rb +1 -1
@@ 1,7 1,7 @@
require_relative 'mailchimp3/endpoint'
require_relative 'mailchimp3/errors'

module Mailchimp3
module MailChimp3
  module_function
  def new(*args)
    Endpoint.new(*args)

M lib/mailchimp3/endpoint.rb => lib/mailchimp3/endpoint.rb +1 -1
@@ 1,7 1,7 @@
require 'faraday'
require 'faraday_middleware'

module Mailchimp3
module MailChimp3
  class Endpoint
    attr_reader :url, :last_result


M lib/mailchimp3/errors.rb => lib/mailchimp3/errors.rb +1 -1
@@ 1,4 1,4 @@
module Mailchimp3
module MailChimp3
  module Errors
    class AuthRequiredError < StandardError; end


M lib/mailchimp3/version.rb => lib/mailchimp3/version.rb +1 -1
@@ 1,3 1,3 @@
module Mailchimp3
module MailChimp3
  VERSION = '0.1.0'
end

M spec/mailchimp3/endpoint_spec.rb => spec/mailchimp3/endpoint_spec.rb +4 -4
@@ 1,7 1,7 @@
require_relative '../spec_helper'
require 'json'

describe Mailchimp3::Endpoint do
describe MailChimp3::Endpoint do
  let(:base) { described_class.new(basic_auth_key: 'key-us2') }

  subject { base }


@@ 70,7 70,7 @@ describe Mailchimp3::Endpoint do
      it 'raises a NotFound error' do
        error = begin
                  subject.get
                rescue Mailchimp3::Errors::NotFound => e
                rescue MailChimp3::Errors::NotFound => e
                  e
                end
        expect(error.status).to eq(404)


@@ 96,7 96,7 @@ describe Mailchimp3::Endpoint do
      it 'raises a ClientError error' do
        expect {
          subject.get
        }.to raise_error(Mailchimp3::Errors::ClientError)
        }.to raise_error(MailChimp3::Errors::ClientError)
      end
    end



@@ 118,7 118,7 @@ describe Mailchimp3::Endpoint do
      it 'raises a ServerError error' do
        expect {
          subject.get
        }.to raise_error(Mailchimp3::Errors::ServerError)
        }.to raise_error(MailChimp3::Errors::ServerError)
      end
    end
  end