mikamai / akamai_api

Akamai gem+CLI to work with CCU and ECCU interfaces
MIT License
43 stars 19 forks source link

Fix CpCode getter. Create a CpCode item for each XML item in the respons... #8

Closed sebfie closed 11 years ago

sebfie commented 11 years ago

...e and return it. (Also fixed tests)

sebfie commented 11 years ago

It's my first pull request, do no hesitate to make me a feedback.

I am using your gem and I got an error trying to get CpCodes, so, I decided to fix it and share my fix. I did not written tests because you already tested this code but tests failed.

My patch fix tests and code.

nicolaracco commented 11 years ago

Thank you for your pull request :)

Instead of doing all that changes, couldn't you convert the result in an array with Array::wrap ? Something like:

    response = client.request('getCPCodes').body[:multi_ref]
    Array.wrap(response).map do |hash|
      ...
    end

For me specs are working. Can you open an issue with the error you are receiving and your ruby version ?

Thank you again

sebfie commented 11 years ago

Did you try when the response has only one CpCode? Look my second commit : https://github.com/Ditchou/akamai_api/commit/598995f9fda57a9b4da9d153de74dedd5640a3b7

nicolaracco commented 11 years ago

Yes, I saw it. I would use Array::wrap exactly for this purpose: Array::wrap doc In practice Array.wrap(response) will return response if response is an Array. If response is an hash (like in your case, with only one cpcode), it will return [response]

sebfie commented 11 years ago

I will do that tomorrow :) Thx

Le 26 févr. 2013 à 23:14, Nicola Racco notifications@github.com a écrit :

Yes, I saw it. I would use Array::wrap exactly for this purpose: Array::wrap doc In practice Array.wrap(response) will return response if response is an Array. If response is an hash (like in your case, with only one cpcode), it will return [response]

— Reply to this email directly or view it on GitHub.