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

Is there a better way to query for our users component? #179

Open
mdonagh opened this issue Nov 11, 2020 · 0 comments
Open

Is there a better way to query for our users component? #179

mdonagh opened this issue Nov 11, 2020 · 0 comments

Comments

@mdonagh
Copy link

mdonagh commented Nov 11, 2020

Something about the map feels wonky, and I couldn't figure out how to query directly by name

  def add_users_self_service(users_to_add)
    return "billing not integrated for this customer" unless chargify_id
    subscription = Chargify::Customer.find(chargify_id).subscriptions.first
    user_billing_component = subscription.components.select{|c| c.attributes['name'] == 'Users'}.first
    user_billing_component.allocated_quantity = user_billing_component.allocated_quantity + users_to_add
    user_billing_component.save
  end
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