urbanairship / ruby-library

A Ruby wrapper for the Urban Airship API.
Other
200 stars 117 forks source link

Retrieving .from_url for a scheduled push errors out #104

Closed rmathew1992 closed 7 years ago

rmathew1992 commented 7 years ago

I'm running version 3.2.4 of the gem.

I run into the following when trying to retrieve a scheduled push notification from UrbanAirship using the .from_url method.

TypeError: no implicit conversion of Hash into String

I'm doing the following:

ua = Urbanairship
airship = ua::Client.new(key: URBAN_AIRSHIP_KEY, secret: URBAN_AIRSHIP_MASTER_SECRET)
ua::Push::ScheduledPush.from_url(
                 client: airship,
                 url: lookup_url
               )

Where lookup_url is a valid UA url that I obtained from creating a scheduled push. After opening up the library I found that in lib/push.rb we were doing the following:

scheduled_push = ScheduledPush.new(client)
        response_body = client.send_request(
          method: 'GET',
          body: nil,
          url: url
        )

        payload = JSON.load(response_body)

Where response body was already a valid ruby object changing payload = JSON.load(response_body) to payload = response_body['body'] fixed my problem.

I would open up a PR for this but I was running into some problems getting the tests to run on my machine.

Also this documentation appears to be incorrect, I wasn't sure who to contact about that: http://docs.urbanairship.com/reference/libraries/ruby/3.2.4/push.html#updating-or-canceling-a-schedule

pdxmele commented 7 years ago

Hi, please reach out to our support team at http://support.urbanairship.com for these kinds of issues and questions instead of posting an issue here. Thank you!