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

Does this gem offer a better way to query for component price points? #181

Open
mdonagh opened this issue Apr 21, 2021 · 0 comments
Open

Comments

@mdonagh
Copy link

mdonagh commented Apr 21, 2021

Hi, we've been using this gem at my company for Chargify integrations.

However, I could not find a way to query for component price points, which I need to do for displaying prices in-app.

Any recommendations on how I could do this with the gem? I could only get it to work by using the REST API directly as seen below

require 'uri'
require 'net/http'

component = Chargify::Subscription.find("SUBSCRIPTION_ID").components.select{|c| c.attributes['name'] == 'Users'}.first.price_points
url = URI("https://test.chargify.com/components/#{component.id}/price_points.json")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
enc   = Base64.strict_encode64('CHARGIFY_KEY_HERE:x')
request["authorization"] = "Basic #{enc}"request.body = "{}"
response = http.request(request)
puts response.read_body
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

No branches or pull requests

1 participant