Sha256: f6e6d49427a97887d7d83578ae1a725f33203812ea43805a082fe3eb75ecba4b

Contents?: true

Size: 981 Bytes

Versions: 12

Compression:

Stored size: 981 Bytes

Contents

module BunnyApp
  class Usage
    @feature_usage_create_mutation = <<-'GRAPHQL'
    mutation featureUsageCreate ($attributes: FeatureUsageAttributes!) {
        featureUsageCreate (attributes: $attributes) {
            errors
            featureUsage {
                id
                quantity
                usageAt
                tenant {
                    id
                    code
                    name
                }
                feature {
                    id
                    code
                    name
                }
            }
        }
    }
    GRAPHQL

    def self.track(quantity:, feature_code:, tenant_code:, usage_at: nil)
      variables = {
        attributes: {
          quantity:,
          featureCode: feature_code,
          tenantCode: tenant_code
        }
      }

      variables[:attributes][:usageAt] = usage_at unless usage_at.nil?

      Client.new.query(@feature_usage_create_mutation, variables)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bunny_app-1.30.0 lib/bunny_app/usage.rb
bunny_app-1.29.0 lib/bunny_app/usage.rb
bunny_app-1.27.0 lib/bunny_app/usage.rb
bunny_app-1.28.0 lib/bunny_app/usage.rb
bunny_app-1.26.0 lib/bunny_app/usage.rb
bunny_app-1.25.0 lib/bunny_app/usage.rb
bunny_app-1.24.0 lib/bunny_app/usage.rb
bunny_app-1.23.0 lib/bunny_app/usage.rb
bunny_app-1.22.0 lib/bunny_app/usage.rb
bunny_app-1.20.0 lib/bunny_app/usage.rb
bunny_app-1.19.0 lib/bunny_app/usage.rb
bunny_app-1.18.0 lib/bunny_app/usage.rb