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

enable adapterOptions to be used in buildURL method #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Falibur
Copy link

@Falibur Falibur commented Jun 12, 2018

This change would enable me to use adapterOptions to differentiate the buildURL per custom api endpoint. Probably this is something others would like as well.

@Techn1x
Copy link

Techn1x commented Jun 14, 2018

I wouldn't hold your breath on getting this merged, it seems the maintainer is a bit busy. Lots of other good PR's not getting merged or even responded to.

It looks like this PR allows creation of different URLs for the same memberAction/collectionAction, by changing the adapterOptions when making the call, and then having something in buildURL deal with that. Looks good to me. You might want to add some tests though.

I'd also like to see the payload passed in to the buildURL as the query argument, so that I can use my application adapter's functions to process that payload in some way (but this would be for a separate PR) edit: ended up making a PR -> #215


Just for those that come here wanting to simply change the built url per api endpoint (rather than per call of that endpoint), I think you can potentially already do this, by setting urlType in the memberAction/collectionAction like so;

ripen: memberAction({
    path: 'ripen',
    type: 'post', // HTTP POST request
    urlType: 'customType' // Base of the URL that's generated for the action
  })

urlType is then available in the buildURL method as the requestType arg. So then in your buildURL you do something like;

buildURL(modelName, id, snapshot, requestType, query) {
  if(requestType === 'customType') {
    return this.urlForCustomType(...);  // Create your custom URL here
  } else {
    return this._super(...arguments);
  }
}

This way each memberAction/collectionAction endpoint you create can have its own URL

@Falibur Falibur force-pushed the support-snapshot-adapteroptions branch from 93f3fad to 9ed5abb Compare April 9, 2019 07:43
@ghost
Copy link

ghost commented Apr 9, 2019

There were the following issues with this Pull Request

  • Commit: 9ed5abb
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@Falibur Falibur force-pushed the support-snapshot-adapteroptions branch from 9ed5abb to 3e80d0e Compare April 9, 2019 08:24
@ghost
Copy link

ghost commented Apr 9, 2019

There were the following issues with this Pull Request

  • Commit: 3e80d0e
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

@Falibur Falibur force-pushed the support-snapshot-adapteroptions branch from 3e80d0e to f4be757 Compare October 10, 2019 08:13
@ghost
Copy link

ghost commented Oct 10, 2019

There were the following issues with this Pull Request

  • Commit: f4be757
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

mrloop added a commit to mrloop/mike-north-ember-api-actions that referenced this pull request Mar 22, 2021
Allows api actions to take an optional `options` object. If you pass an
object on the adapterOptions property of the options argument it will be
passed to your adapter via the snapshot.

Similar to ember data Store and Modal functions, for example
https://api.emberjs.com/ember-data/3.25/classes/Store/methods/findAll?anchor=findAll
https://api.emberjs.com/ember-data/3.25/classes/Model/methods/save?anchor=save

This is similar to mike-north#214 with tests.

Closes mike-north#214
@mrloop mrloop mentioned this pull request Mar 22, 2021
mrloop added a commit to mrloop/mike-north-ember-api-actions that referenced this pull request Mar 22, 2021
Allows api actions to take an optional `options` object. If you pass an
object on the adapterOptions property of the options argument it will be
passed to your adapter via the snapshot.

Similar to ember data Store and Modal functions, for example
https://api.emberjs.com/ember-data/3.25/classes/Store/methods/findAll?anchor=findAll
https://api.emberjs.com/ember-data/3.25/classes/Model/methods/save?anchor=save

This is similar to mike-north#214 with tests.

Closes mike-north#214
mrloop added a commit to mrloop/mike-north-ember-api-actions that referenced this pull request Jul 7, 2021
Allows api actions to take an optional `options` object. If you pass an
object on the adapterOptions property of the options argument it will be
passed to your adapter via the snapshot.

Similar to ember data Store and Modal functions, for example
https://api.emberjs.com/ember-data/3.25/classes/Store/methods/findAll?anchor=findAll
https://api.emberjs.com/ember-data/3.25/classes/Model/methods/save?anchor=save

This is similar to mike-north#214 with tests.

Closes mike-north#214
@Falibur Falibur force-pushed the support-snapshot-adapteroptions branch from 98e0a1f to f4be757 Compare January 5, 2022 16:45
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.

None yet

2 participants