Sha256: 0d33397eea8fd06f3a6058aef3a33920532ee382ded9ee01db1af45258f3dd45

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module BunnyApp
  class Tenant
    @tenant_create_mutation = <<-'GRAPHQL'
    mutation tenantCreate ($attributes: TenantAttributes!) {
      tenantCreate (attributes: $attributes) {
        tenant {
          code
          id
          name
          platform {
            id
            name
            code
          }
        }
        errors
      }
    }
    GRAPHQL

    @tenant_query = <<-'GRAPHQL'
    query tenant ($code: String!) {
      tenant (code: $code) {
        id
        code
        name
        subdomain
        account {
          id
          name
          billingDay
        }
        latestProvisioningChange {
            change
            createdAt
            features
            id
            updatedAt
        }
      }
    }
    GRAPHQL

    def self.create(name:, code:, account_id:, platform_code: 'main')
      variables = {
        attributes: {
          name:,
          code:,
          platformCode: platform_code,
          accountId: account_id
        }
      }

      res = Client.new.query(@tenant_create_mutation, variables)
      res['data']['tenantCreate']['tenant']
    end

    def self.find_by(code:)
      variables = {
        code:
      }

      res = Client.new.query(@tenant_query, variables)
      res['data']['tenant']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunny_app-2.0.4 lib/bunny_app/tenant.rb
bunny_app-2.0.1 lib/bunny_app/tenant.rb
bunny_app-2.0.0 lib/bunny_app/tenant.rb