README.md in paypal-rest-api-0.0.2 vs README.md in paypal-rest-api-0.0.3

- old
+ new

@@ -14,13 +14,11 @@ - Automatically added Paypal-Request-Id header for idempotent requests if not provided; ## Usage -- All APIs accept `:query`, `:body` and `:headers` keyword parameters. -- Some APIs (like show, update, delete) require positional parameters with ID of - a resource. +- All APIs accept optional `:query`, `:body` and `:headers` keyword parameters. - Response has `#body` method to get parsed JSON body. This body has `symbolized` hash keys. - Response contains methods to get original HTTP response. - Failed request error (for non `2**` status codes) contains HTTP request and response @@ -32,25 +30,25 @@ client_id: ENV['PAYPAL_CLIENT_ID'], client_secret: ENV['PAYPAL_CLIENT_SECRET'], live: false ) -# APIs calls examples: +# Usage example: response = client.orders.create(body: body) response = client.orders.show(order_id) -response = client.payments.capture(authorization_id, headers: headers) +response = client.authorized_payments.capture(authorization_id, headers: headers) response = client.webhooks.list(query: query) -# Client can be used directly to send request to any path +# Client also can send requests directly, bypassing specific resources methods response = client.post(path, query: query, body: body, headers: headers) response = client.get(path, query: query, body: body, headers: headers) response = client.patch(path, query: query, body: body, headers: headers) response = client.put(path, query: query, body: body, headers: headers) response = client.delete(path, query: query, body: body, headers: headers) # Getting response -response.body # parsed JSON. Parsed with `JSON.load(http_body, symbolyzed_keys: true)` +response.body # Parsed JSON. JSON is parsed lazyly, keys are symbolized. response[:foo] # Gets :foo attribute from parsed body response.fetch(:foo) # Fetches :foo attribute from parsed body response.http_response # original Net::HTTP::Response response.http_body # original response string response.http_status # Integer http status @@ -139,27 +137,28 @@ All APIs can raise error in case of network error or non-2xx response status code. Errors structure: - `PaypalAPI::Error` - - `PaypalAPI::NetworkError` - any network error - - `PaypalAPI::FailedRequest` - any non-2xx code error - - 400 - `PaypalAPI::BadRequestError` - - 401 - `PaypalAPI::UnauthorizedError` - - 403 - `PaypalAPI::ForbiddenError` - - 404 - `PaypalAPI::NotFoundError` - - 405 - `PaypalAPI::MethodNotAllowedError` - - 406 - `PaypalAPI::NotAcceptableError` - - 409 - `PaypalAPI::ConflictError` - - 415 - `PaypalAPI::UnsupportedMediaTypeError` - - 422 - `PaypalAPI::UnprocessableEntityError` - - 429 - `PaypalAPI::TooManyRequestsError` - - 5xx - `PaypalAPI::FatalError` - - 500 - `PaypalAPI::InternalServerError` - - 503 - `PaypalAPI::ServiceUnavailableError` + - `PaypalAPI::Errors::NetworkError` - any network error + - `PaypalAPI::Errors::FailedRequest` - any non-2xx code error + - 400 - `PaypalAPI::Errors::BadRequest` + - 401 - `PaypalAPI::Errors::Unauthorized` + - 403 - `PaypalAPI::Errors::Forbidden` + - 404 - `PaypalAPI::Errors::NotFound` + - 405 - `PaypalAPI::Errors::MethodNotAllowed` + - 406 - `PaypalAPI::Errors::NotAcceptable` + - 409 - `PaypalAPI::Errors::Conflict` + - 415 - `PaypalAPI::Errors::UnsupportedMediaType` + - 422 - `PaypalAPI::Errors::UnprocessableEntity` + - 429 - `PaypalAPI::Errors::TooManyRequests` + - 5xx - `PaypalAPI::Errors::FatalError` + - 500 - `PaypalAPI::Errors::InternalServerError` + - 503 - `PaypalAPI::Errors::ServiceUnavailable` All errors have additional methods: +- `#paypal_request_id` - PayPal-Request-Id header sent with request - `#response` - Original response object, can be nil in case of NetworkError - `#request` - Original request object - `#error_name` - Original error name - `#error_message` - Original PayPal error `:message` or error `:description` - `#error_debug_id` - Paypal debug_id found in response