Invite Company

Invite a company to join the TNID ecosystem.

The company GraphQL API is accessible at /company

  • As much as possible data should be included in the invitation model so the invitee can only verify and confirm entered data (of course, they can change if necessary)

  • As part of the invitation, at least one person needs to be included in the invitation so that after they register they can take over the management of the newly created company

  • Connection request needs to be confirmed/accepted by the newly created company legal representative.

  • Most properties are flagged private so the newly created company data is not exposed

mutation (
	$company: CompanyInput!
	$representatives: [InviteUserInput!]!
	$connectionType: B2bConnectionType!
  ) {
	createB2bInvite (
  	company: $company
  	representatives: $representatives
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id,
    	legalName,
    	brandName,
    	taxId
      }
    }
  }

Example Code

import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def invite_company(bearer_token, company_to_invite = None, company_representatives = None, connection_type = None):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
        """
            mutation (
                $company: CompanyInput!
                $representatives: [InviteUserInput!]!
                $connectionType: B2bConnectionType!
              ) {
                createB2bInvite (
                company: $company
                representatives: $representatives
                connectionType: $connectionType
                ) {
                id
                status
                type
                insertedAt
                respondedAt
                updatedAt
                company {
                    id
                }
                user {
                    id
                }
                invitedCompany {
                    id,
                    legalName,
                    brandName,
                    taxId
                  }
                }
              }
        """
    )

    params = { "company": company_to_invite, "representatives": company_representatives, "connectionType": connection_type }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
company_to_invite = { "legalName": "Acme Metals" }
company_representative = { "email": "[email protected]", "first_name": "Jane", "last_name": "Smith" }

token = "your_company_token"
invite_company(token, company_to_invite, company_representative, "PARTNER")

Last updated

Was this helpful?