ember-api-actions icon indicating copy to clipboard operation
ember-api-actions copied to clipboard

enable adapterOptions to be used in buildURL method

Open Falibur opened this issue 6 years ago • 4 comments

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.

Falibur avatar Jun 12 '18 13:06 Falibur

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 -> https://github.com/mike-north/ember-api-actions/pull/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

Techn1x avatar Jun 14 '18 01:06 Techn1x

There were the following issues with this Pull Request

  • Commit: 9ed5abbb29cb775f888259d50bbd2ce61f0748a1
    • ✖ 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!

ghost avatar Apr 09 '19 07:04 ghost

There were the following issues with this Pull Request

  • Commit: 3e80d0e838f1d82cc8329723b7088de979257448
    • ✖ 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!

ghost avatar Apr 09 '19 08:04 ghost

There were the following issues with this Pull Request

  • Commit: f4be7576405d98b3caab82962212d7207092d755
    • ✖ 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!

ghost avatar Oct 10 '19 08:10 ghost