## Unreleased
#
## Version 2.8.0 – April 5th, 2018 ##

- Implement API version 2.11 changes
#
## Version 2.8.0 – March 26, 2018 ##

- Implement API version 2.10 changes

### Upgrade Notes

#### 1. InvoiceCollection

When creating invoices or using `mark_failed()`, we now return an `InvoiceCollection` object rather than an `Invoice`. If you wish to upgrade your application without changing functionality, we recommend that you use the `charge_invoice` on the `InvoiceCollection`. Example:

```python
# Change This:
invoice = account.invoice()

# To this
collection = account.invoice()
invoice = collection.charge_invoice
```

Calls that now return `InvoiceCollection` instead of `Invoice`:

* `Purchase#invoice()`
* `Purchase#preview()`
* `Purchase#authorize()`
* `Account#invoice()`
* `Account#build_invoice()`

Furthermore, `Invoice#mark_failed()` no longer updates the invoice but rather returns a new `InvoiceCollection` object:

```python
# Change This:
invoice.mark_failed()

# To this
collection = invoice.mark_failed()
failed_invoice = collection.charge_invoice
```

#### 2. Invoice#original_invoice removed

`Invoice#original_invoice` was removed in favor of `Invoice#original_invoices`. If you want to maintain functionality, change your code grab the first invoice from that endpoint:

```python
# Change this
original_invoice = invoice.original_invoice()

# To this
original_invoice = invoice.original_invoices()[0]
```

#### 3. Invoice `subtotal_*` changes

We have renamed two of the invoice subtotal fields to more clearly reflect their values: 
- Renamed `subtotal_in_cents` to `subtotal_before_discount_in_cents`
- Renamed `subtotal_after_discount_in_cents` to `subtotal_in_cents`

#### 4. Invoice Refund -- `refund_apply_order` changed to `refund_method`

If you were using `Invoice#refund` or `Invoice#refund_amount` and explicitly setting the second `refund_apply_order` parameter, then you may need to change value to fit the new `refund_method` format. The values for this have changed from (`credit`, `transaction`) to (`credit_first`, `transaction_first`)

If you don't explicitly set the `refund_apply_order` like in these two calls, no change is needed:
```python
invoice.refund(line_items);
invoice.refund_amount(1000);
```

If you do set the second param, you'll need to change:
* `credit` to `credit_first`
* `transaction` to `transaction_first`

Examples:
```python
# Change `credit`:
invoice.refund(line_items, 'credit');
invoice.refund_amount(1000, 'credit');

# To `credit_first`
invoice.refund(line_items, 'credit_first');
invoice.refund_amount(1000, 'credit_first');

# Change `transaction`
invoice.refund(line_items, 'transaction');
invoice.refund_amount(1000, 'transaction');

# To `transaction_first`
invoice.refund(line_items, 'transaction_first');
invoice.refund_amount(1000, 'transaction_first');
```

#### 5. Invoice States

If you are checking `Invoice#state` anywhere, you will want to check that you have the new correct values. `collected` has changed to `paid` and `open` has changed to `pending`. Example:

```python
# Change this
if invoice.state == 'collected':
#To this
if invoice.state == 'paid':
```
```python
# Change this
if invoice.state == 'open':
# To this
if invoice.state == 'pending':
```

This also affects the `Invoice.all_collected` and `Invoice.all_open` functions. Example:

```python
# Change this
Invoice.all_collected()
# To this
Invoice.all_paid()
```
```python
# Change this
Invoice.all_open()
# To this
Invoice.all_pending()
```

#
## Version 2.7.0 – November 20, 2017 ##

- Implement API version 2.9 changes

### Upgrade Notes

This version bumps us to API version 2.9. There are a few breaking changes.

1. The `subscription` link on an instance of `Adjustment` is now only created if adjustment is
originating from a subscription plan charge, setup fee, add on, trial or proration credit.
It is no longer created for other adjustments.

2. Instances of `Transaction` and `Invoice` no longer have a `subscription` link and you
must now use the `subscriptions` link.

## Version 2.6.2 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.6.1 October 26, 2017

- Added missing attributes on Delivery resource

## Version 2.6.0 October 12, 2017

This brings us to API version 2.8.

- imported_trial flag on Subscription
- Purchases endpoint
- Support multiple suberrors per field in ValidationError

### Upgrade Notes

There are two breaking changes in this API version you must consider. 

#### Country Codes

All `country` fields must now contain valid [2 letter ISO 3166 country codes](https://www.iso.org/iso-3166-country-codes.html). If your country code fails validation, you will receive a validation error. This affects any endpoint where an address is collected.

#### Purchase Currency

The purchases endpoint can create and invoice multiple adjustments at once but our invoices can only contain items in one currency. To make this explicit the currency can no longer be provided on an adjustment, it must be set once for the entire purchase:

```python
purchase = recurly.Purchase(
  # The purchase object is the only place you can set the currency:
  currency = 'USD',
  account = recurly.Account(
    account_code = 'someone',
  ),
  adjustments = [
      # Remove this currency
      # You can no longer set the currency on adjustment level
      recurly.Adjustment(currency='USD', unit_amount_in_cents=1000, description='Item 1',
                         quantity=1),
  ]
)
```

## Version 2.5.1 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.5.0 April 17, 2017

- Remove parsing of X-Records header
- Cardless Free Trial changes for 2.6

### Upgrade Notes

This release will upgrade us to API version 2.6. There are two breaking changes:

1. Since the X-Records header was removed in the pagination endpoint, you can no longer call `len()` on a Page and expect it to return a cached response.
From now on you need to explicitly call the `count()` class method on a Page. See [PR #202](https://github.com/recurly/recurly-client-python/pull/202) for more information.
2. For `POST /v2/subscriptions` Sending `None` for `total_billing_cycles` attribute will now override plan `total_billing_cycles` setting and will make subscription renew forever.
Omitting the attribute will cause the setting to default to the value of plan `total_billing_cycles`.

## Version 2.4.5 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.4.4 March 23, 2017

- Add API version 2.5 changes

## Version 2.4.3 February 6, 2017

- Add canceled_at, preview, and redeem-on-account support for gift cards
- Add timestamps to `MeasuredUnit`
- Add Account acquisition endpoint
- Add cached rate limiting headers
- Add canceled at, preview, and redeem-on-account support to gift cards

## Version 2.4.2 September 12, 2016

- Add ability to create shipping address on existing account

## Version 2.4.1 August 30, 2016

- Shipping address support

## Version 2.4.0 August 18, 2016

- Fix revenue schedule typo
- Remove old python references from readme
- Gift card support, bumps to api v 2.4
- Add updated_at fields

## Version 2.3.1 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.3.0 July 6, 2016

- Adding variable for api version in fixtures
- Adding `usage_percentage` and `optional` to `AddOn`
- Upgrade API to version 2.3

## Version 2.2.22 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.2.21 June 29, 2016

- Adding `collection_path` to `MeasuredUnit`
- Adding `TransactionError` parsing inside `ValidationError`

## Version 2.2.20 May 23, 2016

- Add `ConfigurationException` when API_KEY or SUBDOMAIN is unicode
- Add transaction_error_code property to ValidationError class
- Fix apply timeout to connection object
- Add python 3.5 to travis tests
- Add fraud info if available on `Transaction`
- Add Usage Based Billing
- Add generator comprehensions in js module
- Add Free Trial Coupons

## Version 2.2.19 February 22, 2016

- Added `currency` attribute to the `BillingInfo` class

## Version 2.2.18 February 11, 2016

- Add `mark_failed` API call to `Invoice`
- Add the python version to the user agent string
- Fix the `delete_url` on the Redemption class by removing the override
- Add support for `cc_emails` attribute in `Account` class
- Remove AttributeError when trying to print ValidationError in Python 3
- Remove _ValidatedHTTPSConnection in favor of native functionality
- Add collection_method and net_terms attributes for invoice calls

## Version 2.2.17 October 2, 2015

- Add support for bulk coupons and coupon code generation
- Add support for editing and restoring coupons

## Version 2.2.16 September 30, 2015

- Remove TLS 1.0 flag allowing proper TLS negotiation
- Fix recursive call to `str(self)` in python 3

## Version 2.2.15 August 31, 2015

- Add `coupon_codes` to `Subscription`
- Adding `setup_fee_accounting_code` to `Plan`
- Add `total_billing_cycles` to `Plan`
- Add `redemption_resource` to `Coupon`
- Adding X-Api-Version support
- Setting X-Api-Version to 2.1
- Adding `redemptions` to `Account`
- Adding `redemptions` to `Invoice`
- Adding `uuid` to `CouponRedemption`
- Add `applies_to_non_plan_charges` to `Coupon`

## Version 2.2.14 August 10, 2015

- Add `gateway_error_code` to `TransactionError`

## Version 2.2.13 July 31, 2015

- Require a version of six library >= 1.4.0
- Add `tax_exempt`, `tax_code`, `accounting_code` to `Transaction`
- Add `duration` to `Coupon`
- Add `temporal_unit` to `Coupon`
- Add `temporal_amount` to `Coupon`

## Version 2.2.12 June 25, 2015

- Add `ip_address` to `Transaction`
- Add `closed_at` to `Invoice`
- Add `refund_apply_order` to `Invoice` for specifying credits or transactions
to be refunded first

## Version 2.2.11 May 6, 2015

- Add `bank_account_authorized_at` to `Subscription`

## Version 2.2.10 April 28, 2015

- Add `tax_type`, `tax_rate`, `tax_region` to `Adjustment`
- Added `bank_account` type and attributes to `BillingInfo`, these include:
	- `name_on_account`
	- `account_type` (`checking` or `savings`)
	- `last_four`
	- `routing_number`

## Version 2.2.9 February 6, 2015

- Added `original_adjustment()` to `Adjustment` for retrieving the linked
adjustment where the other came from for better accounting purposes

## Version 2.2.8 January 27, 2015

- Added address attribute into preview calls and update invoice notes path
- Added tests for new read-only attribute `vat_location_valid` on `Account`
- Added `invoice_number_prefix` and `invoice_number_with_prefix()` on
`Invoice` for use with the Country Invoice Sequencing feature
- Added support for update_notes path on Subscription
- Added `refund_amount` (open amount refunds) to `Invoice`
- Added `refund` (line item refunds) to `Invoice`

## Version 2.2.7 December 8, 2014

- Added ability to read and write invoice notes
- Added `tax_code` to `plan`, `add_ons`, and `adjustment`
- Added inspection on the details of a `transaction`: `transaction.details`
and `transaction.transaction_error`
- Removed support for SSLv3

## Version 2.2.6 October 31, 2014

- Bug fix: `subscription.invoice` now returns the invoice for subscription
change previewing

## Version 2.2.5 October 21, 2014

- Added invoice previews: `account.build_invoice()`

## Version 2.2.4 September 9, 2014

- Added account entity use code: `account.entity_use_code`
- Added bulk parameter
- Added billing agreement support to BillingInfo

## Version 2.2.3 August 5, 2014

- Added subscription change preview
- Added `remaining_billing_cycles` to subscriptions

## Version 2.2.2 June 25, 2014
- Added subscription preview: `subscription.preview()`

## Version 2.2.1 June 6, 2014
- Added tests for `invoice_description`

## Version 2.2.0 May 14, 2014

- Added tax details to adjustments: `adjustment.tax_details`
- Removed `taxable` support on adjustments
- Added `tax_exempt` to accounts, adjustments and plans
- Added `tax_rate`, `tax_type` to invoices and subscriptions
- Added `tax_in_cents` to subscriptions

## Version 2.1.16 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.1.15 April 8, 2014

- Added token_id support to BillingInfo

## Version 2.1.14 April 8, 2014

- Added support for downloading invoices as PDF
- Bug fix: set timeout specific to Recurly module

## Version 2.1.13 February 20, 2014

- Bug fix: Adjustment.get(uuid) now supported

## Version 2.1.12 July 25, 2013

- Added vat_number on Account Object
- Added fields for account level addresses

## Version 2.1.11 - July 2, 2013

- Added support for manual invoicing fields

## Version 2.1.10 - June 14, 2013 ##

- Bug fix: recurly.js.fetch should use base_uri function

## Version 2.1.3 – May 3, 2013 ##

- Added support for querying notes on an account

## Version 2.1.3 – July 16, 2012 ##

- Allow verification of HTTPS certificates when CA certificates are provided.


## Version 2.1.2 – June 29, 2012 ##

- Properly handle refunding transactions.
- Provide access to plan codes for Coupon resources.
- Package the library with setuptools and include tests in the distribution.


## Version 2.1.1 – March 26, 2012 ##

- Properly handle unicode strings in resource values.
- Apply requested filters when requesting lists (such as
  `account.adjustments(type='credit')`).


## Version 2.1.0 – March 13, 2012 ##

- Updated to use Recurly.js 2.1.
- Raise clearer `PageError` exception when trying to traverse to a pagination
  page that doesn't exist.
- Add missing docstring for `Page.page_for_value()` method.

## Version 2.0.5 – November 9, 2017 ##

- Fix SSRF vuln in Resource.get

## Version 2.0.4 – January 6, 2012 ##

- Complete Recurly.js v2 support by adding missing `sign_subscription()` function.
- Fix access to Subscriptions' add-on amounts, which were erroneously `Money`
  instances instead of integers.
- Add missing `reopen()` method to `Account` instances.
- Improve the message for the error when the API key is not set or incorrect.


## Version 2.0.3 – December 20, 2011 ##

- Send only fields that have changed when updating resources.
- Subscriptions' plan codes are now available in the `plan_code` attribute.
- Pending updates to a Subscription are accessible in its `pending_subscription` attribute.


## Version 2.0.2 – November 4, 2011 ##

- Fixed recurly.js function to sign requests for transactions without existing accounts.
- Fixed bug importing the recurly.js module in the documented way.
- Added missing function to support push notifications.


## Version 2.0.1 – October 27, 2011 ##

- Additional support for subscription and transaction interfaces.


## Version 2.0.0 – October 25, 2011 ##

- Support for v2 API with a new object-oriented interface.


## Version 1.2 – March 11, 2010 ##

- Added 'subdomain' parameter
- Fix authentication header if the username long


## Version 1.1 – February 23, 2010 ##

- Initial release
