|
| 1 | +# Tricky things |
| 2 | + |
| 3 | +`Sales representative` is an admin user(merchant side) who is assigned to work with the company. Thus we can't use exsting `Customer` type for sales representative |
| 4 | + |
| 5 | +# Queries |
| 6 | + |
| 7 | +```graphql |
| 8 | +type Query { |
| 9 | + company: Company @doc(description: "Returns all information about the current Company.") |
| 10 | + checkCompanyEmail(email: String!): CompanyEmailCheckResponse @doc(description: "Returns result of validation whether provided email address is valid for a new Company registration or not.") |
| 11 | + checkCompanyAdminEmail(email: String!): CompanyAdminEmailCheckResponse @doc(description: "Returns result of validation whether provided email address is valid for a Company Administrator registration or not.") |
| 12 | + checkCompanyUserEmail(email: String!): CompanyUserEmailCheckResponse @doc(description: "Returns an object with result of validation whether provided email address is valid for a new Customer - Company User - registration or not.") |
| 13 | + checkCompanyRoleName(name: String!): CompanyRoleNameCheckResponse @doc(description: "Returns result of validation whether provided Role name is available.") |
| 14 | +} |
| 15 | + |
| 16 | +type Company @doc(description: "Company entity output data schema.") { |
| 17 | + id: ID! @doc(description: "Company id.") |
| 18 | + name: String! @doc(description: "Company name.") |
| 19 | + email: String! @doc(description: "Company email address.") |
| 20 | + legal_name: String @doc(description: "Company legal name.") |
| 21 | + vat_id: String @doc(description: "Company VAT/TAX id.") |
| 22 | + reseller_id: String @doc(description: "Company re-seller id.") |
| 23 | + legal_address: CompanyLegalAddress! @doc(description: "Company legal address.") |
| 24 | + company_admin: Customer! @doc(description: "An object containing information about Company Administrator.") |
| 25 | + sales_representative: CompanySalesRepresentative @doc(description: "Company sales representative.") |
| 26 | + payment_methods: [String] @doc(description: "List of payment methods available for a Company.") |
| 27 | + users( |
| 28 | + filter: CompanyUsersFilterInput @doc(description: "Identifies which company users to search for and return."), |
| 29 | + pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. Defaults to 20."), |
| 30 | + currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."), |
| 31 | + ): CompanyUsers @doc(description: "Information about the company users.") |
| 32 | + user(id: ID): Customer @doc(description: "Returns company user for current authenticated Customer or, if id provided, for specific one.") |
| 33 | + roles( |
| 34 | + pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once. Optional. Defaults to 20."), |
| 35 | + currentPage: Int = 1 @doc(description: "Specifies which page of results to return. The default value is 1."), |
| 36 | + ): CompanyRoles! @doc(description: "Returns the list of defined roles at Company.") |
| 37 | + role(id: ID!): CompanyRole @doc(description: "Returns company role by id.") |
| 38 | + acl_resources: [CompanyAclResource]! @doc(description: "Returns the list of all permission resources.") |
| 39 | + hierarchy: CompanyHierarchyOutput! @doc(description: "Returns the complete data about company structure.") |
| 40 | + team(id: ID!): CompanyTeam @doc(description: "Returns company team data by id.") |
| 41 | +} |
| 42 | + |
| 43 | +type CompanyLegalAddress @doc(description: "Company legal address output data schema.") { |
| 44 | + street: [String]! @doc(description: "An array of strings that defines the Company's street address.") |
| 45 | + city: String! @doc(description: "City name.") |
| 46 | + region: CustomerAddressRegion! @doc(description: "An object containing region data for the Company.") |
| 47 | + country_code: CountryCodeEnum! @doc(description: "Country code.") |
| 48 | + postcode: String! @doc(description: "ZIP/postal code.") |
| 49 | + telephone: String! @doc(description: "Company's phone number.") |
| 50 | +} |
| 51 | + |
| 52 | +type CompanyAdmin @doc(description: "Company Administrator (Customer with corresponding privileges) output data schema.") { |
| 53 | + id: ID! @doc(description: "Company Administrator's id.") |
| 54 | + email: String! @doc(description: "Company Administrator email address.") |
| 55 | + firstname: String! @doc(description: "Company Administrator first name.") |
| 56 | + lastname: String! @doc(description: "Company Administrator last name.") |
| 57 | + job_title: String @doc(description: "Company Administrator job title.") |
| 58 | + gender: Int @doc(description: "Company Administrator gender.") |
| 59 | +} |
| 60 | + |
| 61 | +type CompanySalesRepresentative @doc(description: "Company sales representative information output data schema.") { |
| 62 | + email: String! @doc(description: "Sales representative email address.") |
| 63 | + firstname: String! @doc(description: "Sales representative first name.") |
| 64 | + lastname: String! @doc(description: "Sales representative last name.") |
| 65 | +} |
| 66 | + |
| 67 | +type CompanyUsers @doc(description: "Output data schema for an object returned by a Company users search query.") { |
| 68 | + items: [Customer] @doc(description: "An array of 'CompanyUser' objects that match the specified search criteria.") |
| 69 | + total_count: Int @doc(description: "The number of objects returned.") |
| 70 | + page_info: SearchResultPageInfo @doc(description: "Pagination meta data.") |
| 71 | +} |
| 72 | + |
| 73 | +type CompanyRoles @doc(description: "Output data schema for an object returned by a Company roles search query.") { |
| 74 | + items: [CompanyRole] @doc(description: "A list of company roles that match the specified search criteria.") |
| 75 | + total_count: Int @doc(description: "The total number of objects matching the specified filter.") |
| 76 | + page_info: SearchResultPageInfo @doc(description: "Pagination meta data.") |
| 77 | +} |
| 78 | + |
| 79 | +type CompanyRole @doc(description: "Company role output data schema returned in response to a query by Role id.") { |
| 80 | + id: ID! @doc(description: "Role id.") |
| 81 | + name: String! @doc(description: "Role name.") |
| 82 | + users_count: Int @doc(description: "Total number of Users with such Role within Company Hierarchy.") |
| 83 | + permissions: [String] @doc(description: "A list of permission resources defined for a Role.") |
| 84 | +} |
| 85 | + |
| 86 | +type CompanyAclResource @doc(description: "Output data schema for an object with Role permission resource information.") { |
| 87 | + id: ID! @doc(description: "ACL resource id.") |
| 88 | + text: String! @doc(description: "ACL resource label.") |
| 89 | + sortOrder: Int! @doc(description: "ACL resource sort order.") |
| 90 | + children: [CompanyAclResource!] @doc(description: "An array of sub-resources.") |
| 91 | +} |
| 92 | + |
| 93 | +type CompanyRoleNameCheckResponse @doc(description: "Response object schema for a role name validation query.") { |
| 94 | + isNameValid: Boolean! @doc(description: "Role name validation result") |
| 95 | +} |
| 96 | + |
| 97 | +type CompanyUserEmailCheckResponse @doc(description: "Response object schema for a Company User email validation query.") { |
| 98 | + isEmailValid: Boolean! @doc(description: "Email validation result") |
| 99 | +} |
| 100 | + |
| 101 | +type CompanyAdminEmailCheckResponse @doc(description: "Response object schema for a Company Admin email validation query.") { |
| 102 | + isEmailValid: Boolean! @doc(description: "Email validation result") |
| 103 | +} |
| 104 | + |
| 105 | +type CompanyEmailCheckResponse @doc(description: "Response object schema for a Company email validation query.") { |
| 106 | + isEmailValid: Boolean! @doc(description: "Email validation result") |
| 107 | +} |
| 108 | + |
| 109 | +type CompanyHierarchyOutput @doc(description: "Response object schema for a Company Hierarchy query.") { |
| 110 | + structure: CompanyHierarchyElement @doc(description: "An array of Company structure elements.") |
| 111 | + isEditable: Boolean @doc(description: "Flag that defines whether Company Hierarchy can be changed by current User or not.") |
| 112 | + max_nesting: Int @doc(description: "Indicator of maximun nesting of elements within a whole Company Hierarchy.") |
| 113 | +} |
| 114 | + |
| 115 | +type CompanyHierarchyElement @doc(description: "Company Hierarchy element output data schema.") { |
| 116 | + id: ID! @doc(description: "Hierarchy element id.") |
| 117 | + tree_id: ID! @doc(description: "The hierarchical id of the element within a structure. Used for changing element's position in hierarchy.") |
| 118 | + type: String! @doc(description: "Hierarchy element type: 'customer' or a 'team'.") |
| 119 | + text: String! @doc(description: "Hierarchy element name.") |
| 120 | + description: String @doc(description: "Hierarchy element description.") |
| 121 | + children: [CompanyHierarchyElement!] @doc(description: "An array of child elements.") |
| 122 | +} |
| 123 | + |
| 124 | +type CompanyTeam @doc(description: "Company Team entity output data schema.") { |
| 125 | + id: ID! @doc(description: "Team id.") |
| 126 | + name: String! @doc(description: "Team name.") |
| 127 | + description: String @doc(description: "Team description.") |
| 128 | +} |
| 129 | + |
| 130 | +input CompanyUsersFilterInput @doc(description: "Defines the input filters for a Company Users query") { |
| 131 | + status: CompanyUserStatusEnum @doc(description: "Filter Customers by their status within a Company structure. Defaults to 'active'. Required.") |
| 132 | +} |
| 133 | + |
| 134 | +enum CompanyUserStatusEnum @doc(description: "List of available Company user statuses.") { |
| 135 | + ACTIVE @doc(description: "Only active users") |
| 136 | + INACTIVE @doc(description: "Only inactive users") |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +# Mutations |
| 141 | + |
| 142 | +```graphql |
| 143 | +type Mutation { |
| 144 | + createCompany(input: CompanyCreateInput!): CreateCompanyOutput @doc(description:"Create new Company.") |
| 145 | + updateCompany(input: CompanyUpdateInput!): UpdateCompanyOutput @doc(description:"Update Company information.") |
| 146 | + createCompanyUser(input: CompanyUserCreateInput!): CreateCompanyUserOutput @doc(description:"Create new Company User (Customer assigned to Company).") |
| 147 | + updateCompanyUser(input: CompanyUserUpdateInput!): UpdateCompanyUserOutput @doc(description:"Update Company User information.") |
| 148 | + deleteCompanyUser(id: ID!): DeleteCompanyUserOutput @doc(description:"Delete Company User by ID.") |
| 149 | + createCompanyRole(input: CompanyRoleCreateInput!): CreateCompanyRoleOutput @doc(description:"Create new Company role.") |
| 150 | + updateCompanyRole(input: CompanyRoleUpdateInput!): UpdateCompanyRoleOutput @doc(description:"Update Company role data.") |
| 151 | + deleteCompanyRole(id: ID!): DeleteCompanyRoleOutput @doc(description:"Delete Company Role by ID.") |
| 152 | + updateCompanyHierarchy(input: CompanyHierarchyUpdateInput!): UpdateCompanyHierarchyOutput @doc(description:"Update Company Hierarchy element's parent node assignment.") |
| 153 | + createCompanyTeam(input: CompanyTeamCreateInput!): CreateCompanyTeamOutput @doc(description:"Create Company Team.") |
| 154 | + updateCompanyTeam(input: CompanyTeamUpdateInput!): UpdateCompanyTeamOutput @doc(description:"Update Company Team data.") |
| 155 | + deleteCompanyTeam(id: ID!): DeleteCompanyTeamOutput @doc(description:"Delete Company Team entity by ID.") |
| 156 | +} |
| 157 | + |
| 158 | +type CreateCompanyTeamOutput @doc(description: "Create company team output data schema.") { |
| 159 | + team: CompanyTeam! @doc(description: "New company team instance.") |
| 160 | +} |
| 161 | + |
| 162 | +type UpdateCompanyTeamOutput @doc(description: "Update company team output data schema.") { |
| 163 | + team: CompanyTeam! @doc(description: "Updated company team instance.") |
| 164 | +} |
| 165 | + |
| 166 | +type DeleteCompanyTeamOutput @doc(description: "Delete company team output data schema.") { |
| 167 | + status: Boolean! @doc(description: "Status of delete operation: true - success; false - fail.") |
| 168 | +} |
| 169 | + |
| 170 | +type CreateCompanyOutput @doc(description: "Create company output data schema.") { |
| 171 | + company: Company! @doc(description: "New company instance.") |
| 172 | +} |
| 173 | + |
| 174 | +type UpdateCompanyOutput @doc(description: "Update company output data schema.") { |
| 175 | + company: Company! @doc(description: "Updated company instance.") |
| 176 | +} |
| 177 | + |
| 178 | +type CreateCompanyUserOutput @doc(description: "Create company user output data schema.") { |
| 179 | + user: Customer! @doc(description: "New company user instance.") |
| 180 | +} |
| 181 | + |
| 182 | +type UpdateCompanyUserOutput @doc(description: "Update company user output data schema.") { |
| 183 | + user: Customer! @doc(description: "Updated company user instance.") |
| 184 | +} |
| 185 | + |
| 186 | +type DeleteCompanyUserOutput @doc(description: "Delete company user output data schema.") { |
| 187 | + status: Boolean! @doc(description: "Status of delete operation: true - success; false - fail.") |
| 188 | +} |
| 189 | + |
| 190 | +type CreateCompanyRoleOutput @doc(description: "Create company role output data schema.") { |
| 191 | + user: CompanyRole! @doc(description: "New company role instance.") |
| 192 | +} |
| 193 | + |
| 194 | +type UpdateCompanyRoleOutput @doc(description: "Update company role output data schema.") { |
| 195 | + user: CompanyRole! @doc(description: "Updated company role instance.") |
| 196 | +} |
| 197 | + |
| 198 | +type DeleteCompanyRoleOutput @doc(description: "Delete company role output data schema.") { |
| 199 | + status: Boolean! @doc(description: "Status of delete operation: true - success; false - fail.") |
| 200 | +} |
| 201 | + |
| 202 | +type UpdateCompanyHierarchyOutput @doc(description: "Update company hierarchy output data schema.") { |
| 203 | + status: Boolean! @doc(description: "Status of update operation: true - success; false - fail.") |
| 204 | +} |
| 205 | + |
| 206 | + |
| 207 | +input CompanyCreateInput @doc(description: "Defines the Company input data schema for creating a new entity."){ |
| 208 | + company_name: String! @doc(description: "Company name. Required.") |
| 209 | + company_email: String! @doc(description: "Company email address. Required.") |
| 210 | + legal_name: String @doc(description: "Company legal name.") |
| 211 | + vat_tax_id: String @doc(description: "Company VAT/TAX ID.") |
| 212 | + reseller_id: String @doc(description: "Company re-seller ID.") |
| 213 | + legal_address: CompanyLegalAddressCreateInput! @doc(description: "An object containing Company legal address data. Required.") |
| 214 | + company_admin: CompanyAdminInput! @doc(description: "An object containing Company Administrator information. Required.") |
| 215 | +} |
| 216 | + |
| 217 | +input CompanyAdminInput @doc(description: "Defines the Company's Administrator input data schema.") { |
| 218 | + email: String! @doc(description: "Company Administrator's email address. Required.") |
| 219 | + firstname: String! @doc(description: "Company Administrator's first name. Required.") |
| 220 | + lastname: String! @doc(description: "Company Administrator's last name. Required.") |
| 221 | + job_title: String @doc(description: "Company Administrator's custom job title.") |
| 222 | + gender: Int @doc(description: "Company Administrator's gender (Male - 1, Female - 2, Not Specified - 3).") |
| 223 | +} |
| 224 | + |
| 225 | +input CompanyLegalAddressCreateInput @doc(description: "Defines the Company legal address input data schema for creating a new entity.") { |
| 226 | + street: [String!]! @doc(description: "An array of strings that define the Company street address. Required array value for a field with strings as values of array.") |
| 227 | + city: String! @doc(description: "Company's city name. Required.") |
| 228 | + country_id: CountryCodeEnum! @doc(description: "Company's country ID. Required. See 'countries' query. Required.") |
| 229 | + region: CustomerAddressRegionInput! @doc(description: "An object containing the region name and/or region ID. Required.") |
| 230 | + postcode: String! @doc(description: "Company's ZIP/postal code. Required.") |
| 231 | + telephone: String! @doc(description: "Company's phone number. Required.") |
| 232 | +} |
| 233 | + |
| 234 | +input CompanyUpdateInput @doc(description: "Defines the Company input data schema for updating an existing entity. Allows only needed fields to be passed for update.") { |
| 235 | + company_name: String @doc(description: "Company name.") |
| 236 | + company_email: String @doc(description: "Company email address.") |
| 237 | + legal_name: String @doc(description: "Company legal name.") |
| 238 | + vat_tax_id: String @doc(description: "Company VAT/TAX ID.") |
| 239 | + reseller_id: String @doc(description: "Company re-seller ID.") |
| 240 | + legal_address: CompanyLegalAddressUpdateInput @doc(description: "An object containing Company legal address data.") |
| 241 | +} |
| 242 | + |
| 243 | +input CompanyLegalAddressUpdateInput @doc(description: "Defines the Company legal address input data schema for updating an existing entity. Allows only needed fields to be passed for update.") { |
| 244 | + street: [String!] @doc(description: "An array of strings that define the Company street address.") |
| 245 | + city: String @doc(description: "Company's city name.") |
| 246 | + country_id: CountryCodeEnum @doc(description: "Company's country ID. See 'countries' query.") |
| 247 | + region: CustomerAddressRegionInput @doc(description: "An object containing the region name and/or region ID. Required.") |
| 248 | + postcode: String @doc(description: "Company's ZIP/postal code.") |
| 249 | + telephone: String @doc(description: "Company's phone number.") |
| 250 | +} |
| 251 | + |
| 252 | +input CompanyUserCreateInput @doc(description: "Defines the input data schema for creating a new Customer - Company user.") { |
| 253 | + job_title: String! @doc(description: "Company user's job title. Required.") |
| 254 | + role_id: ID! @doc(description: "Company user's role ID. Required.") |
| 255 | + firstname: String! @doc(description: "Company user's first name. Required.") |
| 256 | + lastname: String! @doc(description: "Company user's last name. Required.") |
| 257 | + email: String! @doc(description: "Company user's email address. Required.") |
| 258 | + telephone: String! @doc(description: "Company user's phone number. Required.") |
| 259 | + status: Int! @doc(description: "Company user's status ID. Required.") |
| 260 | + target_id: ID @doc(description: "A target structure element ID within a Company's Hierarchy for a user to be assigned to.") |
| 261 | +} |
| 262 | + |
| 263 | +input CompanyUserUpdateInput @doc(description: "Defines the input data schema for updating an existing Customer - Company user.") { |
| 264 | + id: ID! @doc(description: "Company user's ID (Customer ID). Required.") |
| 265 | + role_id: ID @doc(description: "Company user's role ID.") |
| 266 | + status: Int @doc(description: "Company user's status ID.") |
| 267 | + job_title: String @doc(description: "Company user's job title.") |
| 268 | + firstname: String @doc(description: "Company user's first name.") |
| 269 | + lastname: String @doc(description: "Company user's last name.") |
| 270 | + email: String @doc(description: "Company user's email address.") |
| 271 | + telephone: String @doc(description: "Company user's phone number.") |
| 272 | +} |
| 273 | + |
| 274 | +input CompanyRoleCreateInput @doc(description: "Defines the input data schema for creating a new Company role.") { |
| 275 | + name: String! @doc(description: "Role name. Required.") |
| 276 | + permissions: [String!]! @doc(description: "A list of Role permission resources. Required array value for a field with strings as values of array.") |
| 277 | +} |
| 278 | + |
| 279 | +input CompanyRoleUpdateInput @doc(description: "Defines the input data schema for updating an existing Company role.") { |
| 280 | + id: ID! @doc(description: "Role ID. Required.") |
| 281 | + name: String @doc(description: "Role name.") |
| 282 | + permissions: [String!] @doc(description: "A list of Role permission resources. Array value for a field, if provided, should consist only of string values.") |
| 283 | +} |
| 284 | + |
| 285 | +input CompanyHierarchyUpdateInput @doc(description: "Defines the input data schema for updating the Company Hierarchy.") { |
| 286 | + tree_id: ID! @doc(description: "Company Hierarchy element's hierarchical ID that is being moved to another parent. Required.") |
| 287 | + parent_tree_id: ID! @doc(description: "A target parent element tree ID within a Company's Hierarchy. Required.") |
| 288 | +} |
| 289 | + |
| 290 | +input CompanyTeamCreateInput @doc(description: "Defines the input data schema for creating a new Company team.") { |
| 291 | + name: String! @doc(description: "Team name. Required.") |
| 292 | + description: String @doc(description: "Team description.") |
| 293 | + target_id: ID @doc(description: "A target structure element ID within a Company's Hierarchy for a team to be assigned to.") |
| 294 | +} |
| 295 | + |
| 296 | +input CompanyTeamUpdateInput @doc(description: "Defines the input data schema for updating an existing Company team.") { |
| 297 | + id: ID! @doc(description: "Team ID. Required.") |
| 298 | + name: String @doc(description: "Team name.") |
| 299 | + description: String @doc(description: "Team description.") |
| 300 | +} |
| 301 | +``` |
| 302 | + |
| 303 | +# Existing type modifications |
| 304 | + |
| 305 | +```graphql |
| 306 | +type Customer { |
| 307 | + job_title: String! @doc(description: "Company User job title.") |
| 308 | + role: CompanyRole! @doc(description: "Company User role data (includes permissions).") |
| 309 | + team: CompanyTeam! @doc(description: "Company User team data.") |
| 310 | + telephone: String! @doc(description: "Company User phone number.") |
| 311 | + status: CompanyUserStatusEnum! @doc(description: "Company User status.") |
| 312 | +} |
| 313 | +``` |
0 commit comments