Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new endpoints and move Customer, Plan and Data Sources outside of Import namespace #32

Merged
merged 9 commits into from Jan 6, 2017

Conversation

promulo
Copy link
Contributor

@promulo promulo commented Jan 6, 2017

This PR adds support for new ChartMogul API endpoints and also move some classes outside the Import namespace in order to be compliant with our soon to be published new API structure. Stay tuned.

The current ChartMogul::Import::Customer, ChartMogul::Import::DataSource and ChartMogul::Import::Plan will lose the Import namespace as we move towards a simpler API structure. For now, no changes are made to Enrichment and Metrics namespaces.

Along with that, some new endpoints will now have support:

  • GET /v1/data_sources/:uuid
data_source = ChartMogul::DataSource.retrieve(uuid)
  • GET /v1/plans/:uuid
plan = ChartMogul::Plan.retrieve(uuid)
  • PATCH /v1/plans/:uuid
plan = ChartMogul::Plan.retrieve(uuid)
plan.interval_count = 2
plan.update!
  • DELETE /v1/plans/:uuid
plan = ChartMogul::Plan.retrieve(uuid)
plan.destroy!

@promulo promulo changed the title Support new endpoints and remove Customer, Plan and Data Sources from Import namespace Support new endpoints and move Customer, Plan and Data Sources outside of Import namespace Jan 6, 2017
ds = ChartMogul::DataSource.create!(name: 'TestDS')
ds.send(:set_uuid, 'ds_5ee8bf93-b0b4-4722-8a17-6b624a3af072')

data_source = described_class.retrieve(ds.uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps in this line you also need to use explicit uuid instead of method. Because who knows what happened when you did ds.send(:set_uuid,...):

data_source = described_class.retrieve('ds_5ee8bf93-b0b4-4722-8a17-6b624a3af072')

In general I think it is better to use explicit values in tests, so that if you change something, then you'll need to change test as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

)
plan.send(:set_uuid, 'pl_5ee8bf93-b0b4-4722-8a17-6b624a3af072')

plan = described_class.retrieve(plan.uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

plan = described_class.retrieve('pl_5ee8bf93-b0b4-4722-8a17-6b624a3af072')

plan.interval_count = 2
plan.update!

plan = described_class.retrieve(plan.uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

same with uuid (that's my opinion, of course we can discuss if someone diasgrees)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


it 'retrieves existing data source matching uuid', uses_api: true do
ds = ChartMogul::DataSource.create!(name: 'TestDS')
ds.send(:set_uuid, 'ds_5ee8bf93-b0b4-4722-8a17-6b624a3af072')
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to do this set_uuid?

Copy link
Contributor Author

@promulo promulo Jan 6, 2017

Choose a reason for hiding this comment

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

so the UUID is not randomly generated and VCR won't know how to handle the request

include API::Actions::Destroy

def self.find_by_external_id(external_id)
all(external_id: external_id).first
Copy link
Contributor

Choose a reason for hiding this comment

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

this is bit misleading method. If you have 2 Recurly connectors, you'll be not able to retrieve one of them. In general, if you have two connectors and customers have same external_ids, then only one will be returned here :)

Copy link
Contributor Author

@promulo promulo Jan 6, 2017

Choose a reason for hiding this comment

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

Agreed, but this is not a newly introduced method. Maybe it's better to cover this one in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, just noticed it and wanted to make @ytvinay aware

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

Successfully merging this pull request may close these issues.

None yet

3 participants