Skip to content

Conversation

@blatyo
Copy link
Contributor

@blatyo blatyo commented Nov 7, 2017

Figured I'd do the update incrementally. These are all the API changes listed for 2.5. The ones not checked off, I wasn't sure what to do with. I'm also not sure I'm correctly applying read_only. How can I tell if a field is read only?

  • Route changes:

    • Added PUT /v2/invoices/:invoice_number/collect
  • Request and Response Changes:

    • Changed Subscription response:
      • Added <started_with_gift> element.
      • Added <converted_at> element.
    • Changed Billing Info response:
      • Added <updated_at> element.
    • Changed Coupon response:
      • Added <id> element.
    • Changed Invoice response:
      • Added <subtotal_after_discount_in_cents> element.
      • Added <attempt_next_collection_at> element.
      • Added <recovery_reason> element.
      • Added <all_line_items> link when invoice response only shows first 500 line items.
    • Changed Transaction response:
      • Added <gateway_type> element.
      • Added <origin> element.
      • Added <description> element.
      • Added <message> element.
      • Added <approval_code> element.
      • Added <collected_at> element.
    • Changed Account response:
      • Added <has_live_subscription> element.
      • Added <has_active_subscription> element.
      • Added <has_future_subscription> element.
      • Added <has_canceled_subscription> element.
      • Added <has_past_due_invoice> element.
      • Added GET /v2/invoices/:invoice_number/adjustments
    • Changed Adjustment POST request:
      • Added <product_code> element.
    • Changed Transactions POST request:
      • Added <product_code> element.
    • Changed Invoice Preview POST request:
      • Added optional <currency> element. This change affects all versions of the API.
    • Changed Invoice POST request:
      • Added optional <currency> element. This change affects all versions of the API.

alias Recurly.{Resource, Adjustment, Account, Invoice, Subscription}

@account_endpoint "/accounts/<%= account_code %>/adjustments"
@invoice_endpoint "/invoices/<%= invoice_number %>/adjustments"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be two streamable endpoints now. How should that be handled?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a much cleaner way to implement, but this is how I'd imagine the interface to work:

def stream(options) do
  keys = Keyword.keys(options)
  cond do
    :account_code in keys ->
      {account_code, options} = Keyword.pop_first(options, :account_code)
      Resource.stream(Adjustment, account_path(account_code), options)
    :invoice_number in keys ->
      {invoice_number, options} = Keyword.pop_first(options, :invoice_number)
      Resource.stream(Adjustment, invoice_path(invoice_number), options)
  end
end

# examples:
stream(account_code: "myaccount", order: :desc)
stream(invoice_number: "1001", order: :asc)

@bhelx bhelx self-requested a review November 7, 2017 20:05
Copy link
Owner

@bhelx bhelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your read_only markings look correct. Anything other questions you need answered to finish this?

alias Recurly.{Resource, Adjustment, Account, Invoice, Subscription}

@account_endpoint "/accounts/<%= account_code %>/adjustments"
@invoice_endpoint "/invoices/<%= invoice_number %>/adjustments"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a much cleaner way to implement, but this is how I'd imagine the interface to work:

def stream(options) do
  keys = Keyword.keys(options)
  cond do
    :account_code in keys ->
      {account_code, options} = Keyword.pop_first(options, :account_code)
      Resource.stream(Adjustment, account_path(account_code), options)
    :invoice_number in keys ->
      {invoice_number, options} = Keyword.pop_first(options, :invoice_number)
      Resource.stream(Adjustment, invoice_path(invoice_number), options)
  end
end

# examples:
stream(account_code: "myaccount", order: :desc)
stream(invoice_number: "1001", order: :asc)

@bhelx
Copy link
Owner

bhelx commented Jan 11, 2018

@blatyo Do you have time to keep working on this? If not, I'll pick up the last commit.

@blatyo
Copy link
Contributor Author

blatyo commented Jan 11, 2018

@bhelx Sorry, the approach I took changed for me. It turned out we didn't immediately need any new features. Mostly just support for existing endpoints that weren't setup. These are the changes I'm running with in production at the moment. master...blatyo:master

You're definitely welcome to take this PR over. The remaining bits of our Recurly integration got reprioritized, so I'm focused elsewhere.

@bhelx
Copy link
Owner

bhelx commented Jan 11, 2018

@blatyo thanks. It's no problem. I'll pick up this PR then see what else I can do. I have the feeling I can get this library up to 2.9 without implementing everything.

@iurimadeira
Copy link

iurimadeira commented May 9, 2019

@bhelx This is a really nice library! Are there any plans on continuing with the update to API version 2.9? Or maybe even upgrading it to 2.19?

@bhelx
Copy link
Owner

bhelx commented May 10, 2019

@iurimadeira I check the logs on the server side from time to time looking for this library's user agent. I wasn't aware anyone was using the library so I stopped improving it. Happy to take any PRs you want to apply. It shouldn't be too hard to get it up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants