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

Added Client ability to perform custom GET and POST #31

Merged
merged 2 commits into from
Jan 25, 2017

Conversation

Miguelcldn
Copy link
Contributor

The official MercadoPago ruby SDK supports generic methods in order to access any other resource not available as a method.

I've seen this feature useful because I needed to create a preapproval plan as a POST to /preapproval_plan. Though I could simply add a function to do it, I took the chance to implement generic calls at once.

@Juanmcuello
Copy link

It would be great to have this merged. Is there a chance that anybody take a look at it?

Copy link
Member

@etagwerker etagwerker left a comment

Choose a reason for hiding this comment

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

@Miguelcldn Thanks for your PR!

Please review my comment.

# - url: the URL to request
#
def get(url)
MercadoPago::Request.wrap_get("#{url}?access_token=#{@access_token}")
Copy link
Member

Choose a reason for hiding this comment

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

@Miguelcldn Why didn't you add payload support here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could, just thought it was not necessary. I will now

Choose a reason for hiding this comment

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

@etagwerker , why do you think that's needed? wrap_get does not accept a payload. If you want this method to accept a payload, wrap_get should be modified as well. In addition, the official MP gem does not support a payload either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just realized that too, wrap_get doesn't need a payload.

Choose a reason for hiding this comment

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

@etagwerker , Did you have the chance to see the comments?

Copy link
Member

Choose a reason for hiding this comment

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

@Miguelcldn I'm sorry, I didn't mean "payload", I meant "headers".

Sure, it doesn't need a payload, but someone might want to send specific headers.

See:

def self.wrap_get(path, headers = {})
make_request(:get, path, nil, headers)
end

Also, in Mercado Pago's API doc: https://www.mercadopago.com.ar/developers/en/api-docs/account/movements/

If we are going to add this feature, we should make sure that it's flexible enough to take headers like accept: application/json

Could you change that in the new get and post methods? Just add an optional parameter as the last parameter.

Copy link
Contributor Author

@Miguelcldn Miguelcldn Jan 24, 2017

Choose a reason for hiding this comment

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

Done @etagwerker, I had to change the way default headers were set because if I'd set headers as {} in Client.get then wrap_get would not set the default headers, same for post.

Also, now it supports adding custom query strings.

@etagwerker etagwerker merged commit 2bf39f0 into ombulabs:master Jan 25, 2017
@etagwerker
Copy link
Member

@Miguelcldn Thanks! 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants