Sha256: 97c86aa1febd68f35bbfa028f4960f52c0bfe2d5213e277aaeb59c17a7a213a9

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

module BunnyApp
  class PortalSession
    @portal_session_create_mutation = <<-'GRAPHQL'
    mutation portalSessionCreate ($tenantCode: String!) {
      portalSessionCreate (tenantCode: $tenantCode) {
          token
          errors
      }
    }
    GRAPHQL

    def self.create(tenant_code:, expiry_hours: 24, return_url: nil)
      variables = {
        tenantCode: tenant_code,
        returnUrl: return_url,
        expiry: expiry_hours
      }

      res = Client.new.query(@portal_session_create_mutation, variables)
      raise ResponseError, res['data']['portalSessionCreate']['errors'].join(',') if res['data']['portalSessionCreate']['errors']

      res['data']['portalSessionCreate']['token']
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bunny_app-2.2.0 lib/bunny_app/portal_session.rb
bunny_app-2.1.0 lib/bunny_app/portal_session.rb