TNID
  • Welcome
  • Getting Started
    • Company Authentication
    • User Authentication
    • Accessing via Postman / GraphQL Schema examples
  • Company
    • Search Companies
    • Invite Company
    • List Organization Types
    • List Vertical Types
    • Update Company Profile
    • B2B Features
      • Send B2B Connection Request
      • List B2B Connections
      • List Pending B2B Connection Requests
      • Cancel B2B Connection Request
      • Get Received B2B Connection Requests
      • Respond to B2B Connection Requests
    • B2C Features
      • List B2C (People) Connections
      • List Pending People Connection Requests
      • List Active Subscribers
      • List Pending Subscription Requests
      • Send Person (B2C) Connection Request
      • Invite People (as Company)
      • Send Person (B2C) Subscription Request
      • Cancel Pending B2C Connection Request
      • Cancel Pending B2C Subscription Request
      • Get Pending Connection Requests (People)
      • Respond to C2B Connection Request
      • Get Connected People
      • Search People
      • List Opt-Out Requests
      • Create Opt-out Request
  • User
    • Update User profile
    • Search User (People)
    • Invite User (People)
    • Connections
      • Send C2B Connection Request
      • List B2C connections
      • List received pending B2C Connection Requests
      • Respond to received B2C Connection Request
      • Revoke sent C2B Connection Request
      • List sent pending C2B Connection Requests
    • Spam Reporting Features
      • Create Spam Report
      • List Spam Reports
    • Company Features
      • Search Companies
      • Create company profile
      • List Pending C2C Connection Requests
      • Revoke sent C2C Connection Request
      • List Received C2C Connection Requests
      • Send C2C Connection Request
      • Respond C2C Connection Request
      • List C2C Connections
  • Group Features
    • Search Groups
    • List User's Groups
    • Create Group
    • Update group
    • Invite User to Group
    • Respond to Group invite
    • List pending Group invites (Sent)
    • List pending Group invites (Received)
    • Revoke Pending Group User Member Invite
    • Send Group user member join request
    • List Received Pending Group user member join request
    • List Pending Group user member join request
    • Revoke Group user member join request
    • Respond to Group user member join request
Powered by GitBook
On this page

Was this helpful?

  1. Company

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": "user@acme-metals-domain.com", "first_name": "Jane", "last_name": "Smith" }

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

PreviousSearch CompaniesNextList Organization Types

Last updated 7 months ago

Was this helpful?