From b22203f7301c81a93a5dfc9a2c85793ae7020a1b Mon Sep 17 00:00:00 2001 From: Amelia C <71268735+AmeliaCelline@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:24:07 +0800 Subject: [PATCH] feat: add Freshdesk component (#274) Because - need to add Freshdesk component to make the user story (sync with clients) more complete. This commit TODO: - [x] Get Ticket - [x] Create Ticket - [x] Reply To Ticket - [x] Create Ticket Note - [x] Get All Conversations - [x] Get Contact - [x] Create Contact - [x] Get Company - [x] Create Company - [x] Get All - [x] Get Product - [x] Get Group - [x] Get Agent - [x] Get Skill - [x] Get Role For more information about the component: https://docs.google.com/document/d/1Mky3lDA4iv-Z3p67YqFuRGQd1ImXBxULAjPuXb1VJ38/edit?usp=sharing --- application/freshdesk/v0/README.mdx | 531 ++ application/freshdesk/v0/agent.go | 403 ++ application/freshdesk/v0/agent_test.go | 380 ++ application/freshdesk/v0/assets/Freshdesk.svg | 4 + application/freshdesk/v0/client.go | 91 + application/freshdesk/v0/company.go | 182 + application/freshdesk/v0/company_test.go | 179 + .../freshdesk/v0/config/definition.json | 33 + application/freshdesk/v0/config/setup.json | 42 + application/freshdesk/v0/config/tasks.json | 2466 +++++++++ application/freshdesk/v0/contact.go | 319 ++ application/freshdesk/v0/contact_test.go | 194 + .../v0/freshdesk_interface_mock_test.go | 4805 +++++++++++++++++ application/freshdesk/v0/get_all.go | 125 + application/freshdesk/v0/get_all_test.go | 90 + application/freshdesk/v0/main.go | 327 ++ application/freshdesk/v0/product.go | 81 + application/freshdesk/v0/product_test.go | 88 + application/freshdesk/v0/ticket.go | 710 +++ application/freshdesk/v0/ticket_test.go | 459 ++ store/store.go | 2 + 21 files changed, 11511 insertions(+) create mode 100644 application/freshdesk/v0/README.mdx create mode 100644 application/freshdesk/v0/agent.go create mode 100644 application/freshdesk/v0/agent_test.go create mode 100644 application/freshdesk/v0/assets/Freshdesk.svg create mode 100644 application/freshdesk/v0/client.go create mode 100644 application/freshdesk/v0/company.go create mode 100644 application/freshdesk/v0/company_test.go create mode 100644 application/freshdesk/v0/config/definition.json create mode 100644 application/freshdesk/v0/config/setup.json create mode 100644 application/freshdesk/v0/config/tasks.json create mode 100644 application/freshdesk/v0/contact.go create mode 100644 application/freshdesk/v0/contact_test.go create mode 100644 application/freshdesk/v0/freshdesk_interface_mock_test.go create mode 100644 application/freshdesk/v0/get_all.go create mode 100644 application/freshdesk/v0/get_all_test.go create mode 100644 application/freshdesk/v0/main.go create mode 100644 application/freshdesk/v0/product.go create mode 100644 application/freshdesk/v0/product_test.go create mode 100644 application/freshdesk/v0/ticket.go create mode 100644 application/freshdesk/v0/ticket_test.go diff --git a/application/freshdesk/v0/README.mdx b/application/freshdesk/v0/README.mdx new file mode 100644 index 00000000..b11803df --- /dev/null +++ b/application/freshdesk/v0/README.mdx @@ -0,0 +1,531 @@ +--- +title: "Freshdesk" +lang: "en-US" +draft: false +description: "Learn about how to set up a VDP Freshdesk component https://github.com/instill-ai/instill-core" +--- + +The Freshdesk component is an application component that allows users to use Freshdesk API to manage tickets, contacts and more.. +It can carry out the following tasks: + +- [Get Ticket](#get-ticket) +- [Create Ticket](#create-ticket) +- [Reply To Ticket](#reply-to-ticket) +- [Create Ticket Note](#create-ticket-note) +- [Get All Conversations](#get-all-conversations) +- [Get Contact](#get-contact) +- [Create Contact](#create-contact) +- [Get Company](#get-company) +- [Create Company](#create-company) +- [Get All](#get-all) +- [Get Product](#get-product) +- [Get Agent](#get-agent) +- [Get Role](#get-role) +- [Get Group](#get-group) +- [Get Skill](#get-skill) + + + +## Release Stage + +`Alpha` + + + +## Configuration + +The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/application/freshdesk/v0/config/definition.json). + + + + +## Setup + + +| Field | Field ID | Type | Note | +| :--- | :--- | :--- | :--- | +| API key (required) | `api-key` | string | Fill in your Freshdesk API key. To find your key, go to profile settigs and on the right pane, you can get your key once you have completed the captcha verification. | +| Domain (required) | `domain` | string | Your Freshdesk domain. You can find this by going to Admin -> Search for "Portals" -> Portal URL. Your portal URL will look like "yourdomain.freshdesk.com". Please only input your domain and not the whole URL. | + + + + +## Supported Tasks + +### Get Ticket + +Get ticket using ID + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_TICKET` | +| Ticket ID (required) | `ticket-id` | integer | The ID of the ticket | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Subject | `subject` | string | Subject of the ticket | +| Description Text | `description-text` | string | Content of the ticket | +| Source | `source` | string | Source of the ticket. Eg: Email | +| Status | `status` | string | Status of the ticket. Eg: Pending | +| Priority | `priority` | string | Priority of the ticket. Eg: Medium | +| Ticket Type (optional) | `ticket-type` | string | Used to categorize the ticket. To check the possible types a ticket can have, please go to Admin -> Ticket Fields | +| Association Type (optional) | `association-type` | string | Used to determine whether a ticket is a parent, child, tracker or related ticket | +| Associated Ticket List (optional) | `associated-ticket-list` | array[integer] | List of associated ticket IDs | +| Tags (optional) | `tags` | array[string] | Tags associated with the ticket. | +| CC Emails (optional) | `cc-emails` | array[string] | Email addresses added in the 'cc' field of the incoming ticket email | +| Forward Emails (optional) | `forward-emails` | array[string] | Email addresses added while forwarding a ticket | +| Reply CC Emails (optional) | `reply-cc-emails` | array[string] | Email addresses added while replying to a ticket | +| Requester ID | `requester-id` | integer | ID of the requester | +| Responder ID (optional) | `responder-id` | integer | ID of the agent to whom the ticket has been assigned. List of agents can be found in Admin -> Agents | +| Company ID (optional) | `company-id` | integer | ID of the company to which this ticket belongs | +| Group ID (optional) | `group-id` | integer | ID of the group to which the ticket has been assigned. List of groups can be found in Admin -> Groups | +| Product ID (optional) | `product-id` | integer | ID of the product to which the ticket is associated. List of products can be found in Admin -> Multiple Products | +| Support Email (optional) | `support-email` | string | Support email address. You can find it in Admin -> Email (under channel). | +| To Emails (optional) | `to-emails` | array[string] | Email addresses to which the ticket was originally sent | +| Spam (optional) | `spam` | boolean | Set to true if the ticket is marked as spam | +| Due By (optional) | `due-by` | string | Timestamp that denotes when the ticket is due to be resolved. In UTC format. | +| Is Escalated (optional) | `is-escalated` | boolean | Set to true if the ticket has been escalated | +| First Response Due By (optional) | `first-response-due-by` | string | Timestamp that denotes when the first response is due. In UTC format. You can adjust this by going to Admin -> SLA policy (under Workflows). | +| First Response Escalated (optional) | `first-response-escalated` | boolean | Set to true if the ticket has been escalated as the result of first response time being breached | +| Next Response Due By (optional) | `next-response-due-by` | string | Timestamp that denotes when the next response is due. In UTC format. You can adjust this by going to Admin -> SLA policy (under Workflows). | +| Next Response Escalated (optional) | `next-response-escalated` | boolean | Set to true if the ticket has been escalated as the result of next response time being breached | +| Created At | `created-at` | string | Timestamp that denotes when the ticket/conversation was created. In UTC format. | +| Updated At | `updated-at` | string | Timestamp that denotes when the ticket was last updated. In UTC format. | +| Attachments (optional) | `attachments` | array[object] | Ticket attachments (cannot be more than 20MB) | +| Sentiment Score (optional) | `sentiment-score` | integer | Freshdesk uses AI to assess the emotional tone and attitude expressed in customer interaction. | +| Initial Sentiment Score (optional) | `initial-sentiment-score` | integer | The initial sentiment score of the ticket | +| Custom Fields (optional) | `custom-fields` | object | Custom fields that the ticket have. Custom fields can be created or modified in Admin -> Ticket Fields | + + + + + + +### Create Ticket + +Create ticket + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_CREATE_TICKET` | +| Requester ID | `requester-id` | integer | ID of the requester. Must be an existing contact. If you fill in this field, you don't need to fill in the email field. Only one of the two fields is required. | +| Email | `email` | string | Email address of the requester. If you fill in the Requester ID above, it will be ignored. Only one of the two fields is required. If no contact exists with this email address in Freshdesk, it will be added as a new contact. | +| Subject (required) | `subject` | string | Subject of the ticket | +| Description (required) | `description` | string | Content of the ticket. You can use HTML tags in the content. | +| Source (required) | `source` | string | Source of the ticket. Eg: Email | +| Status (required) | `status` | string | Status of the ticket. Eg: Pending | +| Priority (required) | `priority` | string | Priority of the ticket. Eg: Medium | +| Ticket Type | `ticket-type` | string | Used to categorize the ticket. To check the possible types a ticket can have, please go to Admin -> Ticket Fields | +| Company ID | `company-id` | integer | ID of the company to which this ticket belongs | +| Product ID | `product-id` | integer | ID of the product to which the ticket is associated. List of products can be found in Admin -> Multiple Products | +| Group ID | `group-id` | integer | ID of the group to which the ticket has been assigned. List of groups can be found in Admin -> Groups | +| Responder ID | `responder-id` | integer | ID of the agent to whom the ticket has been assigned. List of agents can be found in Admin -> Agents | +| Tags | `tags` | array[string] | Tags associated with the ticket. | +| CC Emails | `cc-emails` | array[string] | Email addresses added in the 'cc' field of the incoming ticket email | +| Parent ID | `parent-id` | integer | ID of the parent ticket. Need to be filled out if you want to create a child ticket. | +| Related Ticket IDs | `related-ticket-ids` | array[integer] | List of related ticket IDs. Need to be filled out if you want to create a tracker ticket. | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Ticket ID | `ticket-id` | integer | The ID of the ticket | +| Created At | `created-at` | string | Timestamp that denotes when the ticket/conversation was created. In UTC format. | + + + + + + +### Reply To Ticket + +Reply to a ticket thread. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_REPLY_TO_TICKET` | +| Body (required) | `body` | string | Content of the reply. Can be in HTML format. | +| Ticket ID (required) | `ticket-id` | integer | The ID of the ticket | +| From Email | `from-email` | string | Email address that is replying to the ticket. You need to have this email address registered in Freshdesk by going to Admin -> Emails. If you leave this field empty, the global support email will be used. | +| User ID | `user-id` | integer | ID of the agent/contact replying to the ticket. If you fill this field using a contact ID, there will be no email sent to the requester. | +| CC Emails | `cc-emails` | array[string] | Email addresses added in the 'cc' field of the outgoing ticket email. | +| BCC Emails | `bcc-emails` | array[string] | Email addresses added in the 'bcc' field of the outgoing ticket email. | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Conversation ID | `conversation-id` | integer | The ID of the note or reply that is associated with the ticket | +| Created At | `created-at` | string | Timestamp that denotes when the ticket/conversation was created. In UTC format. | + + + + + + +### Create Ticket Note + +Create a private/public note on a ticket thread. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_CREATE_TICKET_NOTE` | +| Ticket ID (required) | `ticket-id` | integer | The ID of the ticket | +| Body (required) | `body` | string | Content of the note. Can be in HTML format. | +| Notify Emails | `notify-emails` | array[string] | Email addresses of agents/users who need to be notified about this note. The emails need to exist in Freshdesk agent. Agent list can be seen in Admin -> Agents. | +| User ID | `user-id` | integer | ID of the agent/contact who is adding the note. | +| Private | `private` | boolean | Set to true if the note is private | +| Incoming | `incoming` | boolean | Set to true if a particular note should appear as being created from outside (i.e., not through web portal). | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Conversation ID | `conversation-id` | integer | The ID of the note or reply that is associated with the ticket | +| Created At | `created-at` | string | Timestamp that denotes when the ticket/conversation was created. In UTC format. | + + + + + + +### Get All Conversations + +Get all the conversations in a ticket. (Conversations are replies and notes that are added to a ticket) + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_ALL_CONVERSATIONS` | +| Ticket ID (required) | `ticket-id` | integer | Ticket ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Conversations | `conversations` | array[object] | An array of conversations | +| Conversations Length | `conversations-length` | integer | Number of conversations | + + + + + + +### Get Contact + +Get contact using ID + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_CONTACT` | +| Contact ID (required) | `contact-id` | integer | ID of the contact | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the contact | +| Email (optional) | `email` | string | The primary email address of the contact | +| Phone (optional) | `phone` | string | Telephone number of the contact | +| Mobile (optional) | `mobile` | string | Mobile number of the contact | +| Description (optional) | `description` | string | Description of the contact | +| Address (optional) | `address` | string | Address of the contact | +| Job Title (optional) | `job-title` | string | Job title of the contact | +| Tags (optional) | `tags` | array[string] | Tags associated with the contact | +| Language (optional) | `language` | string | Language of the contact | +| Time Zone (optional) | `time-zone` | string | Time zone of the contact | +| Company ID (optional) | `company-id` | integer | ID of the primary company to which the contact belongs | +| Unique External ID (optional) | `unique-external-id` | string | Unique external ID of the contact which be assigned by the user(agent) | +| Twitter ID (optional) | `twitter-id` | string | Twitter ID of the contact | +| View All Tickets (optional) | `view-all-tickets` | boolean | Set to true if the contact can see all the tickets that are associated with the primary company. | +| Deleted (optional) | `deleted` | boolean | Set to true if the contact is deleted | +| Active (optional) | `active` | boolean | Set to true if the contact has been verified | +| Other Emails (optional) | `other-emails` | array[string] | List of other email addresses of the contact | +| Other Companies (optional) | `other-companies` | array[object] | List of other companies to which the contact belongs | +| Other Phone Numbers (optional) | `other-phone-numbers` | array[string] | List of other phone numbers of the contact | +| Created At (optional) | `created-at` | string | Timestamp that denotes when the contact was created. In UTC format. | +| Updated At (optional) | `updated-at` | string | Timestamp that denotes when the contact was last updated. In UTC format. | +| Custom Fields (optional) | `custom-fields` | object | Custom fields that the contact have. Custom fields can be created or modified in Admin -> Customer Fields | + + + + + + +### Create Contact + +Create contact + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_CREATE_CONTACT` | +| Name (required) | `name` | string | Name of the contact | +| Email | `email` | string | The primary email address of the contact | +| Phone | `phone` | string | Telephone number of the contact | +| Mobile | `mobile` | string | Mobile number of the contact | +| Description | `description` | string | Description of the contact | +| Address | `address` | string | Address of the contact | +| Job Title | `job-title` | string | Job title of the contact | +| Tags | `tags` | array[string] | Tags associated with the contact | +| Language | `language` | string | Language of the contact | +| Time Zone | `time-zone` | string | Time zone of the contact | +| Company ID | `company-id` | integer | ID of the primary company to which the contact belongs | +| Unique External ID | `unique-external-id` | string | Unique external ID of the contact which be assigned by the user(agent) | +| Twitter ID | `twitter-id` | string | Twitter ID of the contact | +| View All Tickets | `view-all-tickets` | boolean | Used to determine if the contact can see all the tickets that are associated with the primary company. Note: this property will be ignored if the Company ID is not provided. | +| Other Emails | `other-emails` | array[string] | List of other email addresses of the contact | +| Other Companies | `other-companies` | array[string] | List of other companies to which the contact belongs. Each company should be in the format of company-id;view-all-tickets(boolean "true"/"false") Example: 123;true | +| Other Phone Numbers | `other-phone-numbers` | array[string] | List of other phone numbers of the contact | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Contact ID | `contact-id` | integer | ID of the contact | +| Created At | `created-at` | string | Timestamp that denotes when the contact was created. In UTC format. | + + + + + + +### Get Company + +Get company using ID + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_COMPANY` | +| Company ID (required) | `company-id` | integer | ID of the primary company to which the contact belongs | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the company | +| Description (optional) | `description` | string | Description of the company | +| Note (optional) | `note` | string | Note about the company | +| Domains (optional) | `domains` | array[string] | Domains of the company | +| Health Score (optional) | `health-score` | string | The strength of your relationship with the company. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: "At risk", "Doing okay", "Happy" | +| Account Tier (optional) | `account-tier` | string | Classification based on how much value the company brings to your business. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: "Basic", "Premium", "Enterprise" | +| Renewal Date (optional) | `renewal-date` | string | Date when your contract or relationship with the company is due for renewal | +| Industry (optional) | `industry` | string | The industry in which the company operates. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. | +| Created At | `created-at` | string | Timestamp that denotes when the company was created. In UTC format. | +| Updated At | `updated-at` | string | Timestamp that denotes when the company was last updated. In UTC format. | +| Custom Fields (optional) | `custom-fields` | object | Custom fields that the company have. Custom fields can be created or modified in Admin -> Customer Fields | + + + + + + +### Create Company + +Create company + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_CREATE_COMPANY` | +| Name (required) | `name` | string | Name of the company | +| Description | `description` | string | Description of the company | +| Note | `note` | string | Note about the company | +| Domains | `domains` | array[string] | Domains of the company | +| Health Score | `health-score` | string | The strength of your relationship with the company. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: "At risk", "Doing okay", "Happy" | +| Account Tier | `account-tier` | string | Classification based on how much value the company brings to your business. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: "Basic", "Premium", "Enterprise" | +| Renewal Date | `renewal-date` | string | Date when your contract or relationship with the company is due for renewal. Enter in the format YYYY-MM-DD. | +| Industry | `industry` | string | The industry in which the company operates. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Company ID | `company-id` | integer | ID of the company | +| Created At | `created-at` | string | Timestamp that denotes when the company was created. In UTC format. | + + + + + + +### Get All + +Task to get all the IDs of existing contacts, companies, tickets, products, agents, roles, or skills. Note: products, agents, roles, and skills require admin privileges. Some of these might not work, depending on the plan you are on. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_ALL` | +| Object Type (required) | `object-type` | string | Type of object to get IDs for | +| Length (required) | `length` | integer | The maximum number of IDs allowed is 500. The most recent IDs will be retrieved. | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| IDs | `ids` | array[integer] | List of IDs | +| ID Length | `id-length` | integer | Number of IDs | + + + + + + +### Get Product + +Get product using ID. This task will only work if you have admin privileges. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_PRODUCT` | +| Product ID (required) | `product-id` | integer | Product ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the product | +| Description | `description` | string | Description of the product | +| Primary Email | `primary-email` | string | Primary email of the product | +| Created At | `created-at` | string | Timestamp that denotes when the product was created | +| Updated At | `updated-at` | string | Timestamp that denotes when the product was last updated | +| Default | `default` | boolean | Set to true if the product is the default product | + + + + + + +### Get Agent + +Get agent using ID. This task will only work if you have admin privileges. Agents are those in your team who will login to Freshdesk. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_AGENT` | +| Agent ID (required) | `agent-id` | integer | Agent ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name (optional) | `name` | string | Name of the agent | +| Active (optional) | `active` | boolean | Set to true if the agent is verified | +| Email | `email` | string | Email of the agent | +| Job Title (optional) | `job-title` | string | Job title of the agent | +| Language (optional) | `language` | string | Language of the agent | +| Mobile (optional) | `mobile` | string | Mobile number of the agent | +| Phone (optional) | `phone` | string | Telephone number of the agent | +| Time Zone (optional) | `time-zone` | string | Time zone of the agent | +| Type | `type` | string | Type of the agent. Can be "Support Agent", "Field Agent" or "Collaborator" | +| Ticket Scope | `ticket-scope` | string | Ticket permission of the agent. Can be "Global Access", "Group Access" or "Restricted Access" | +| Available (optional) | `available` | boolean | Set to true if the agent is in a group that has enabled "Automatic Ticket Assignment" | +| Group IDs (optional) | `group-ids` | array[integer] | Group IDs of the agent | +| Role IDs (optional) | `role-ids` | array[integer] | Role IDs of the agent | +| Skill IDs (optional) | `skill-ids` | array[integer] | Skill IDs of the agent | +| Occasional | `occasional` | boolean | Set to true if the agent is not working full-time | +| Signature (optional) | `signature` | string | Signature of the agent in HTML format | +| Focus Mode (optional) | `focus-mode` | boolean | Set to true if the agent is in focus mode | +| Deactivated (optional) | `deactivated` | boolean | Set to true if the agent is deactivated | +| Created At (optional) | `created-at` | string | Timestamp that denotes when the agent was created | +| Updated At (optional) | `updated-at` | string | Timestamp that denotes when the agent was last updated | + + + + + + +### Get Role + +Get role using ID. This task will only work if you have admin privileges. Roles allow agents/collaborators to have different privileges. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_ROLE` | +| Role ID (required) | `role-id` | integer | Role ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the role | +| Description | `description` | string | Description of the role | +| Default | `default` | boolean | Set to true if the role is the default role | +| Agent Type | `agent-type` | string | Type of the agent. Can be "Support Agent", "Field Agent" or "Collaborator" | +| Created At | `created-at` | string | Timestamp that denotes when the role was created | +| Updated At | `updated-at` | string | Timestamp that denotes when the role was last updated | + + + + + + +### Get Group + +Get group using ID. This task will only work if you have admin privileges. Agents can be classified into groups such as Customer Support. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_GROUP` | +| Group ID (required) | `group-id` | integer | Group ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the group | +| Description | `description` | string | Description of the group | +| Agent IDs (optional) | `agent-ids` | array[integer] | Agent IDs of the group | +| Auto Ticket Assign | `auto-ticket-assign` | string | The type of automatic ticket assignment set for the group. | +| Escalate To (optional) | `escalate-to` | integer | The ID of the user to whom an escalation email is sent if a ticket is unassigned. | +| Unassigned Duration (optional) | `unassigned-duration` | string | The duration for which a ticket is unassigned before it is escalated. | +| Group Type (optional) | `group-type` | string | Group type. Can be "support_agent_group" or "field_agent_group" | +| Agent Availability Status (optional) | `agent-availability-status` | boolean | The availability status of the agent in the group. Automatically set to true if the group has enabled "Automatic Ticket Assignment". | +| Created At | `created-at` | string | Timestamp that denotes when the group was created | +| Updated At | `updated-at` | string | Timestamp that denotes when the group was last updated | + + + + + + +### Get Skill + +Get skill using ID. This task will only work if you have admin privileges. Agents can be assigned skills, and it is possible for tickets to be automatically assigned to agents based on the skills they have. + + +| Input | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Task ID (required) | `task` | string | `TASK_GET_SKILL` | +| Skill ID (required) | `skill-id` | integer | Skill ID | + + + +| Output | ID | Type | Description | +| :--- | :--- | :--- | :--- | +| Name | `name` | string | Name of the skill | +| Rank | `rank` | integer | Rank of the skill | +| Condition Match Type | `condition-match-type` | string | Type of condition match. Can be "all" or "any" | +| Conditions | `conditions` | array | Conditions for the skill | +| Created At | `created-at` | string | Timestamp that denotes when the skill was created | +| Updated At | `updated-at` | string | Timestamp that denotes when the skill was last updated | + + + + + + + diff --git a/application/freshdesk/v0/agent.go b/application/freshdesk/v0/agent.go new file mode 100644 index 00000000..0d49bf9e --- /dev/null +++ b/application/freshdesk/v0/agent.go @@ -0,0 +1,403 @@ +package freshdesk + +import ( + "fmt" + + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +// This file is used to handle "Get Agent", "Get Role", "Get Skill" and "Get Group" tasks. +// Role, Skill and Group are common to all agents, so they are handled in the same file. + +const ( + AgentPath = "agents" + RolePath = "roles" + GroupPath = "groups" + SkillPath = "admin/skills" +) + +// API function for Agent + +func (c *FreshdeskClient) GetAgent(agentID int64) (*TaskGetAgentResponse, error) { + resp := &TaskGetAgentResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", AgentPath, agentID)); err != nil { + return nil, err + } + return resp, nil +} + +// API function for Role + +func (c *FreshdeskClient) GetRole(roleID int64) (*TaskGetRoleResponse, error) { + resp := &TaskGetRoleResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", RolePath, roleID)); err != nil { + return nil, err + } + return resp, nil +} + +// API function for Group + +func (c *FreshdeskClient) GetGroup(groupID int64) (*TaskGetGroupResponse, error) { + resp := &TaskGetGroupResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", GroupPath, groupID)); err != nil { + return nil, err + } + return resp, nil +} + +// API function for Skill + +func (c *FreshdeskClient) GetSkill(skillID int64) (*TaskGetSkillResponse, error) { + resp := &TaskGetSkillResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", SkillPath, skillID)); err != nil { + return nil, err + } + return resp, nil +} + +// Task 1: Get Agent + +type TaskGetAgentInput struct { + AgentID int64 `json:"agent-id"` +} + +type TaskGetAgentResponse struct { + Contact taskGetAgentResponseContact `json:"contact"` + Type string `json:"type"` + TicketScope int `json:"ticket_scope"` + Available bool `json:"available"` + GroupIDs []int64 `json:"group_ids"` + RoleIDs []int64 `json:"role_ids"` + SkillIDs []int64 `json:"skill_ids"` + Occasional bool `json:"occasional"` + Signature string `json:"signature"` + FocusMode bool `json:"focus_mode"` + Deactivated bool `json:"deactivated"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +type taskGetAgentResponseContact struct { + Name string `json:"name"` + Active bool `json:"active"` + Email string `json:"email"` + JobTitle string `json:"job_title"` + Language string `json:"language"` + LastLoginAt string `json:"last_login_at"` + Mobile string `json:"mobile"` + Phone string `json:"phone"` + TimeZone string `json:"time_zone"` +} + +type TaskGetAgentOutput struct { + Name string `json:"name,omitempty"` + Active bool `json:"active"` + Email string `json:"email"` + JobTitle string `json:"job-title,omitempty"` + Language string `json:"language,omitempty"` + LastLoginAt string `json:"last-login-at"` + Mobile string `json:"mobile,omitempty"` + Phone string `json:"phone,omitempty"` + TimeZone string `json:"time-zone,omitempty"` + Type string `json:"type"` + TicketScope string `json:"ticket-scope"` + Available bool `json:"available"` + GroupIDs []int64 `json:"group-ids"` + RoleIDs []int64 `json:"role-ids"` + SkillIDs []int64 `json:"skill-ids"` + Occasional bool `json:"occasional"` + Signature string `json:"signature,omitempty"` + FocusMode bool `json:"focus-mode"` + Deactivated bool `json:"deactivated"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` +} + +func (e *execution) TaskGetAgent(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetAgentInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetAgent(inputStruct.AgentID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetAgentOutput{ + Name: resp.Contact.Name, + Active: resp.Contact.Active, + Email: resp.Contact.Email, + JobTitle: resp.Contact.JobTitle, + Language: convertCodeToLanguage(resp.Contact.Language), + LastLoginAt: convertTimestampResp(resp.Contact.LastLoginAt), + Mobile: resp.Contact.Mobile, + Phone: resp.Contact.Phone, + TimeZone: resp.Contact.TimeZone, + Type: resp.Type, + TicketScope: convertTicketScopeResponse(resp.TicketScope), + Available: resp.Available, + GroupIDs: resp.GroupIDs, + RoleIDs: resp.RoleIDs, + SkillIDs: resp.SkillIDs, + Occasional: resp.Occasional, + Signature: resp.Signature, + FocusMode: resp.FocusMode, + Deactivated: resp.Deactivated, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 2: Get Role +type TaskGetRoleInput struct { + RoleID int64 `json:"role-id"` +} + +type TaskGetRoleResponse struct { + Description string `json:"description"` + Name string `json:"name"` + Default bool `json:"default"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + AgentType int `json:"agent_type"` +} + +type TaskGetRoleOutput struct { + Description string `json:"description"` + Name string `json:"name"` + Default bool `json:"default"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` + AgentType string `json:"agent-type"` +} + +func (e *execution) TaskGetRole(in *structpb.Struct) (*structpb.Struct, error) { + + inputStruct := TaskGetRoleInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetRole(inputStruct.RoleID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetRoleOutput{ + Description: resp.Description, + Name: resp.Name, + Default: resp.Default, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + AgentType: convertAgentTypeResponse(resp.AgentType), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil + +} + +// Task 3: Get Group +type TaskGetGroupInput struct { + GroupID int64 `json:"group-id"` +} + +type TaskGetGroupResponse struct { + Name string `json:"name"` + Description string `json:"description"` + AgentIDs []int64 `json:"agent_ids"` + AutoTicketAssign int `json:"auto_ticket_assign"` + EscalateTo int64 `json:"escalate_to"` + UnassignedDuration string `json:"unassigned_for"` + GroupType string `json:"group_type"` + AgentAvailabilityStatus bool `json:"agent_availability_status"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +type TaskGetGroupOutput struct { + Name string `json:"name"` + Description string `json:"description"` + AgentIDs []int64 `json:"agent-ids"` + AutoTicketAssign string `json:"auto-ticket-assign"` + EscalateTo int64 `json:"escalate-to,omitempty"` + UnassignedDuration string `json:"unassigned-duration,omitempty"` + GroupType string `json:"group-type,omitempty"` + AgentAvailabilityStatus bool `json:"agent-availability-status"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` +} + +func (e *execution) TaskGetGroup(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetGroupInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetGroup(inputStruct.GroupID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetGroupOutput{ + Name: resp.Name, + AgentIDs: resp.AgentIDs, + AutoTicketAssign: convertAutoTicketAssignResponse(resp.AutoTicketAssign), + Description: resp.Description, + EscalateTo: resp.EscalateTo, + UnassignedDuration: resp.UnassignedDuration, + GroupType: resp.GroupType, + AgentAvailabilityStatus: resp.AgentAvailabilityStatus, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil + +} + +// Task 4: Get Skill + +type TaskGetSkillInput struct { + SkillID int64 `json:"skill-id"` +} + +type TaskGetSkillResponse struct { + Name string `json:"name"` + Rank int `json:"rank"` + Conditions []taskGetSkillResponseCondition `json:"conditions"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +type taskGetSkillResponseCondition struct { + ChannelConditions []taskGetSkillResponseChannelCondition `json:"channel_conditions"` +} + +type taskGetSkillResponseChannelCondition struct { + MatchType string `json:"match_type"` + Properties []map[string]interface{} `json:"properties"` +} + +type TaskGetSkillOutput struct { + Name string `json:"name"` + Rank int `json:"rank"` + ConditionMatchType string `json:"condition-match-type"` + Conditions []map[string]interface{} `json:"conditions"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` +} + +func (e *execution) TaskGetSkill(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetSkillInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetSkill(inputStruct.SkillID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetSkillOutput{ + Name: resp.Name, + Rank: resp.Rank, + ConditionMatchType: resp.Conditions[0].ChannelConditions[0].MatchType, //only Condition[0] and ChannelCondition[0] are taken because no matter what kind of skill I make, there is only one of each. + Conditions: resp.Conditions[0].ChannelConditions[0].Properties, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +func convertTicketScopeResponse(in int) string { //used in Get Agent task + switch in { + case 1: + return "Global Access" + case 2: + return "Group Access" + case 3: + return "Restricted Access" + default: + return "Unknown" + } +} + +func convertAgentTypeResponse(in int) string { //used in Get Role task + switch in { + case 1: + return "Support Agent" + case 2: + return "Field Agent" + case 3: + return "Collaborator" + default: + return "Unknown agent type" + } +} + +func convertAutoTicketAssignResponse(in int) string { + switch in { + case 0: + return "Disabled" + case 1: + return "Round Robin" + case 2: + return "Skill Based Round Robin" + case 3: + return "Load Based Round Robin" + case 12: + return "Omniroute" + default: + return "Unknown automatic ticket assign type" + } +} diff --git a/application/freshdesk/v0/agent_test.go b/application/freshdesk/v0/agent_test.go new file mode 100644 index 00000000..60898836 --- /dev/null +++ b/application/freshdesk/v0/agent_test.go @@ -0,0 +1,380 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +func TestComponent_ExecuteGetAgentTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetAgentMock. + When(154023630520). + Then( + &TaskGetAgentResponse{ + Contact: taskGetAgentResponseContact{ + Name: "Fake Agent", + Email: "randomemail@gmail.com", + JobTitle: "Random Job Title", + Language: "ja-JP", + Phone: "1234567890", + TimeZone: "Santiago", + }, + Type: "collaborator", + TicketScope: 2, + Available: false, + GroupIDs: []int64{154000444629}, + RoleIDs: []int64{154001049982, 154001049983}, + SkillIDs: []int64{1}, + Occasional: false, + Signature: "Random Signature", + FocusMode: true, + Deactivated: false, + CreatedAt: "2024-08-29T10:03:14Z", + UpdatedAt: "2024-08-29T10:03:14Z", + }, nil) + + tc := struct { + name string + input TaskGetAgentInput + wantOutput TaskGetAgentOutput + }{ + name: "ok - task get agent", + input: TaskGetAgentInput{ + AgentID: 154023630520, + }, + wantOutput: TaskGetAgentOutput{ + Name: "Fake Agent", + Email: "randomemail@gmail.com", + JobTitle: "Random Job Title", + Language: "Japanese", + Phone: "1234567890", + TimeZone: "Santiago", + Type: "collaborator", + TicketScope: "Group Access", + Available: false, + GroupIDs: []int64{154000444629}, + RoleIDs: []int64{154001049982, 154001049983}, + SkillIDs: []int64{1}, + Occasional: false, + Signature: "Random Signature", + FocusMode: true, + Deactivated: false, + CreatedAt: "2024-08-29 10:03:14 UTC", + UpdatedAt: "2024-08-29 10:03:14 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetAgent}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetAgent + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteGetRoleTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetRoleMock. + When(154001049978). + Then( + &TaskGetRoleResponse{ + Description: "Has complete control over the help desk and the organisation including access to Account or Billing related information, and receives Invoices.", + Name: "Fake Role", + Default: true, + CreatedAt: "2024-08-18T03:47:58Z", + UpdatedAt: "2024-08-18T03:47:58Z", + AgentType: 1, + }, nil) + + tc := struct { + name string + input TaskGetRoleInput + wantOutput TaskGetRoleOutput + }{ + name: "ok - task get role", + input: TaskGetRoleInput{ + RoleID: 154001049978, + }, + wantOutput: TaskGetRoleOutput{ + Description: "Has complete control over the help desk and the organisation including access to Account or Billing related information, and receives Invoices.", + Name: "Fake Role", + Default: true, + CreatedAt: "2024-08-18 03:47:58 UTC", + UpdatedAt: "2024-08-18 03:47:58 UTC", + AgentType: "Support Agent", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetRole}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetRole + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteGetGroupTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetGroupMock. + When(154000458525). + Then( + &TaskGetGroupResponse{ + Name: "Random Group", + Description: "Just a random group", + AgentIDs: []int64{154023114553}, + AutoTicketAssign: 12, + EscalateTo: 154023114553, + UnassignedDuration: "8h", + GroupType: "support_agent_group", + AgentAvailabilityStatus: true, + CreatedAt: "2024-08-29T10:31:44Z", + UpdatedAt: "2024-08-29T10:31:44Z", + }, nil) + + tc := struct { + name string + input TaskGetGroupInput + wantOutput TaskGetGroupOutput + }{ + name: "ok - task get group", + input: TaskGetGroupInput{ + GroupID: 154000458525, + }, + wantOutput: TaskGetGroupOutput{ + Name: "Random Group", + Description: "Just a random group", + AgentIDs: []int64{154023114553}, + AutoTicketAssign: "Omniroute", + EscalateTo: 154023114553, + UnassignedDuration: "8h", + GroupType: "support_agent_group", + AgentAvailabilityStatus: true, + CreatedAt: "2024-08-29 10:31:44 UTC", + UpdatedAt: "2024-08-29 10:31:44 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetGroup}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetGroup + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteGetSkillTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetSkillMock. + When(1). + Then( + &TaskGetSkillResponse{ + Name: "Random Skill", + Rank: 2, + CreatedAt: "2024-08-22T09:14:32Z", + UpdatedAt: "2024-08-22T12:56:57Z", + Conditions: []taskGetSkillResponseCondition{ + { + ChannelConditions: []taskGetSkillResponseChannelCondition{ + { + MatchType: "any", + Properties: []map[string]interface{}{ + { + "value": []interface{}{3}, + "operator": "in", + "field_name": "priority", + "resource_type": "ticket", + }, + { + "value": []interface{}{"zh-CN"}, + "operator": "in", + "field_name": "language", + "resource_type": "contact", + }, + }, + }, + }, + }, + }, + }, nil) + + tc := struct { + name string + input TaskGetSkillInput + wantOutput TaskGetSkillOutput + }{ + name: "ok - task get skill", + input: TaskGetSkillInput{ + SkillID: 1, + }, + wantOutput: TaskGetSkillOutput{ + Name: "Random Skill", + Rank: 2, + CreatedAt: "2024-08-22 09:14:32 UTC", + UpdatedAt: "2024-08-22 12:56:57 UTC", + ConditionMatchType: "any", + Conditions: []map[string]interface{}{ + { + "value": []interface{}{3}, + "operator": "in", + "field_name": "priority", + "resource_type": "ticket", + }, + { + "value": []interface{}{"zh-CN"}, + "operator": "in", + "field_name": "language", + "resource_type": "contact"}, + }, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetSkill}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetSkill + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/application/freshdesk/v0/assets/Freshdesk.svg b/application/freshdesk/v0/assets/Freshdesk.svg new file mode 100644 index 00000000..c06d053e --- /dev/null +++ b/application/freshdesk/v0/assets/Freshdesk.svg @@ -0,0 +1,4 @@ + + + + diff --git a/application/freshdesk/v0/client.go b/application/freshdesk/v0/client.go new file mode 100644 index 00000000..f68f299f --- /dev/null +++ b/application/freshdesk/v0/client.go @@ -0,0 +1,91 @@ +package freshdesk + +import ( + "encoding/base64" + "fmt" + + "github.com/instill-ai/component/internal/util/httpclient" + "go.uber.org/zap" + "google.golang.org/protobuf/types/known/structpb" +) + +func newClient(setup *structpb.Struct, logger *zap.Logger) *FreshdeskClient { + basePath := fmt.Sprintf("https://%s.freshdesk.com/api", getDomain(setup)) + + c := httpclient.New("Freshdesk", basePath+"/"+version, + httpclient.WithLogger(logger), + httpclient.WithEndUserError(new(errBody)), + ) + + c.Header.Set("Authorization", getAPIKey(setup)) + + w := &FreshdeskClient{httpclient: c} + + return w +} + +// sometimes it will give an array of errors, other times it wont. +type errBody struct { + Description string `json:"description"` + Errors []struct { + Field string `json:"field"` + Message string `json:"message"` + Code string `json:"code"` + } `json:"errors"` + ErrorMessage string `json:"message"` +} + +func (e errBody) Message() string { + var errReturn string + for index, err := range e.Errors { + if index > 0 { + errReturn += ". " + } + + errReturn += err.Message + if err.Field != "" { + errReturn += ", field: " + err.Field + } + if err.Code != "" { + errReturn += ", code: " + err.Code + } + } + + errReturn += e.ErrorMessage + + return errReturn +} + +func getAPIKey(setup *structpb.Struct) string { + apiKey := setup.GetFields()["api-key"].GetStringValue() + + // In Freshdesk, the format is api-key:X. Afterward, it needs to be encoded in base64 + encodedKey := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:X", apiKey))) + return encodedKey +} + +func getDomain(setup *structpb.Struct) string { + return setup.GetFields()["domain"].GetStringValue() +} + +type FreshdeskClient struct { + httpclient *httpclient.Client +} + +type FreshdeskInterface interface { + GetTicket(ticketID int64) (*TaskGetTicketResponse, error) + CreateTicket(req *TaskCreateTicketReq) (*TaskCreateTicketResponse, error) + ReplyToTicket(ticketID int64, req *TaskReplyToTicketReq) (*TaskReplyToTicketResponse, error) + CreateTicketNote(ticketID int64, req *TaskCreateTicketNoteReq) (*TaskCreateTicketNoteResponse, error) + GetContact(contactID int64) (*TaskGetContactResponse, error) + CreateContact(req *TaskCreateContactReq) (*TaskCreateContactResponse, error) + GetCompany(companyID int64) (*TaskGetCompanyResponse, error) + CreateCompany(req *TaskCreateCompanyReq) (*TaskCreateCompanyResponse, error) + GetAll(objectType string, pagination bool, paginationPath string) ([]TaskGetAllResponse, string, error) + GetAllConversations(ticketID int64, pagination bool, paginationPath string) ([]TaskGetAllConversationsResponse, string, error) + GetProduct(productID int64) (*TaskGetProductResponse, error) + GetAgent(agentID int64) (*TaskGetAgentResponse, error) + GetRole(roleID int64) (*TaskGetRoleResponse, error) + GetGroup(groupID int64) (*TaskGetGroupResponse, error) + GetSkill(skillID int64) (*TaskGetSkillResponse, error) +} diff --git a/application/freshdesk/v0/company.go b/application/freshdesk/v0/company.go new file mode 100644 index 00000000..6fa2a0c9 --- /dev/null +++ b/application/freshdesk/v0/company.go @@ -0,0 +1,182 @@ +package freshdesk + +import ( + "fmt" + + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +const ( + CompanyPath = "companies" +) + +// API functions for Company + +func (c *FreshdeskClient) GetCompany(companyID int64) (*TaskGetCompanyResponse, error) { + resp := &TaskGetCompanyResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", CompanyPath, companyID)); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) CreateCompany(req *TaskCreateCompanyReq) (*TaskCreateCompanyResponse, error) { + resp := &TaskCreateCompanyResponse{} + + httpReq := c.httpclient.R().SetBody(req).SetResult(resp) + if _, err := httpReq.Post("/" + CompanyPath); err != nil { + return nil, err + } + return resp, nil + +} + +// Task 1: Get Company + +type TaskGetCompanyInput struct { + CompanyID int64 `json:"company-id"` +} + +type TaskGetCompanyResponse struct { + Name string `json:"name"` + Description string `json:"description"` + Note string `json:"note"` + Domains []string `json:"domains"` + HealthScore string `json:"health_score"` + AccountTier string `json:"account_tier"` + RenewalDate string `json:"renewal_date"` + Industry string `json:"industry"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + CustomFields map[string]interface{} `json:"custom_fields"` +} + +type TaskGetCompanyOutput struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + Note string `json:"note,omitempty"` + Domains []string `json:"domains"` + HealthScore string `json:"health-score,omitempty"` + AccountTier string `json:"account-tier,omitempty"` + RenewalDate string `json:"renewal-date,omitempty"` + Industry string `json:"industry,omitempty"` + CreatedAt string `json:"created-at,omitempty"` + UpdatedAt string `json:"updated-at,omitempty"` + CustomFields map[string]interface{} `json:"custom-fields,omitempty"` +} + +func (e *execution) TaskGetCompany(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetCompanyInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetCompany(inputStruct.CompanyID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetCompanyOutput{ + Name: resp.Name, + Description: resp.Description, + Note: resp.Note, + Domains: *checkForNilString(&resp.Domains), + HealthScore: resp.HealthScore, + AccountTier: resp.AccountTier, + RenewalDate: convertTimestampResp(resp.RenewalDate), + Industry: resp.Industry, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + } + + if len(resp.CustomFields) > 0 { + outputStruct.CustomFields = resp.CustomFields + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 2: Create Company + +type TaskCreateCompanyInput struct { + Name string `json:"name"` + Description string `json:"description"` + Note string `json:"note"` + Domains []string `json:"domains"` + HealthScore string `json:"health-score"` + AccountTier string `json:"account-tier"` + RenewalDate string `json:"renewal-date"` + Industry string `json:"industry"` +} + +type TaskCreateCompanyReq struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + Note string `json:"note,omitempty"` + Domains []string `json:"domains,omitempty"` + HealthScore string `json:"health_score,omitempty"` + AccountTier string `json:"account_tier,omitempty"` + RenewalDate string `json:"renewal_date,omitempty"` + Industry string `json:"industry,omitempty"` +} + +type TaskCreateCompanyResponse struct { + ID int64 `json:"id"` + CreatedAt string `json:"created_at"` +} + +type TaskCreateCompanyOutput struct { + ID int64 `json:"company-id"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskCreateCompany(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskCreateCompanyInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + req := &TaskCreateCompanyReq{ + Name: inputStruct.Name, + Description: inputStruct.Description, + Note: inputStruct.Note, + Domains: inputStruct.Domains, + HealthScore: inputStruct.HealthScore, + AccountTier: inputStruct.AccountTier, + RenewalDate: inputStruct.RenewalDate, + Industry: inputStruct.Industry, + } + + resp, err := e.client.CreateCompany(req) + + if err != nil { + return nil, err + } + + outputStruct := TaskCreateCompanyOutput{ + ID: resp.ID, + CreatedAt: convertTimestampResp(resp.CreatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} diff --git a/application/freshdesk/v0/company_test.go b/application/freshdesk/v0/company_test.go new file mode 100644 index 00000000..a499d536 --- /dev/null +++ b/application/freshdesk/v0/company_test.go @@ -0,0 +1,179 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +func TestComponent_ExecuteGetCompanyTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetCompanyMock. + When(154001162614). + Then( + &TaskGetCompanyResponse{ + Name: "Fake Company", + Description: "This is a fake company", + Note: "A note for fake company", + Domains: []string{"random@company.com", "random2@company.com"}, + HealthScore: "Doing okay", + AccountTier: "Premium", + RenewalDate: "2024-08-29T00:00:00Z", + Industry: "Diversified Consumer Services", + CreatedAt: "2024-08-29T06:25:48Z", + UpdatedAt: "2024-08-29T06:25:48Z", + }, nil) + + tc := struct { + name string + input TaskGetCompanyInput + wantOutput TaskGetCompanyOutput + }{ + name: "ok - task get company", + input: TaskGetCompanyInput{ + CompanyID: 154001162614, + }, + wantOutput: TaskGetCompanyOutput{ + Name: "Fake Company", + Description: "This is a fake company", + Note: "A note for fake company", + Domains: []string{"random@company.com", "random2@company.com"}, + HealthScore: "Doing okay", + AccountTier: "Premium", + RenewalDate: "2024-08-29 00:00:00 UTC", + Industry: "Diversified Consumer Services", + CreatedAt: "2024-08-29 06:25:48 UTC", + UpdatedAt: "2024-08-29 06:25:48 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetCompany}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetCompany + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteCreateCompanyTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.CreateCompanyMock. + When( + &TaskCreateCompanyReq{ + Name: "Fake Company", + Description: "This is a fake company", + Note: "A note for fake company", + Domains: []string{"randomdomain.com", "randomdomain2.com"}, + HealthScore: "At risk", + AccountTier: "Basic", + RenewalDate: "2024-08-30", + Industry: "Automotive", + }). + Then(&TaskCreateCompanyResponse{ + ID: 154001162922, + CreatedAt: "2024-08-29T08:23:15Z", + }, nil) + + tc := struct { + name string + input TaskCreateCompanyInput + wantOutput TaskCreateCompanyOutput + }{ + name: "ok - task create company", + input: TaskCreateCompanyInput{ + Name: "Fake Company", + Description: "This is a fake company", + Note: "A note for fake company", + Domains: []string{"randomdomain.com", "randomdomain2.com"}, + HealthScore: "At risk", + AccountTier: "Basic", + RenewalDate: "2024-08-30", + Industry: "Automotive", + }, + wantOutput: TaskCreateCompanyOutput{ + ID: 154001162922, + CreatedAt: "2024-08-29 08:23:15 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskCreateCompany}, + client: FreshdeskClientMock, + } + e.execute = e.TaskCreateCompany + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/application/freshdesk/v0/config/definition.json b/application/freshdesk/v0/config/definition.json new file mode 100644 index 00000000..1d070cc0 --- /dev/null +++ b/application/freshdesk/v0/config/definition.json @@ -0,0 +1,33 @@ +{ + "availableTasks": [ + "TASK_GET_TICKET", + "TASK_CREATE_TICKET", + "TASK_REPLY_TO_TICKET", + "TASK_CREATE_TICKET_NOTE", + "TASK_GET_ALL_CONVERSATIONS", + "TASK_GET_CONTACT", + "TASK_CREATE_CONTACT", + "TASK_GET_COMPANY", + "TASK_CREATE_COMPANY", + "TASK_GET_ALL", + "TASK_GET_PRODUCT", + "TASK_GET_AGENT", + "TASK_GET_ROLE", + "TASK_GET_GROUP", + "TASK_GET_SKILL" + ], + "documentationUrl": "https://www.instill.tech/docs/component/application/freshdesk", + "icon": "assets/Freshdesk.svg", + "id": "freshdesk", + "public": true, + "title": "Freshdesk", + "description": "Use Freshdesk API to manage tickets, contacts and more.", + "tombstone": false, + "type": "COMPONENT_TYPE_APPLICATION", + "uid": "e89b5830-bc28-4886-9e04-e3db6e0efe9f", + "vendor": "Freshdesk", + "vendorAttributes": {}, + "version": "0.1.0", + "sourceUrl": "https://github.com/instill-ai/component/blob/main/application/freshdesk/v0", + "releaseStage": "RELEASE_STAGE_ALPHA" +} diff --git a/application/freshdesk/v0/config/setup.json b/application/freshdesk/v0/config/setup.json new file mode 100644 index 00000000..2225c867 --- /dev/null +++ b/application/freshdesk/v0/config/setup.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, + "properties": { + "api-key": { + "description": "Fill in your Freshdesk API key. To find your key, go to profile settigs and on the right pane, you can get your key once you have completed the captcha verification.", + "instillUpstreamTypes": [ + "reference" + ], + "instillAcceptFormats": [ + "string" + ], + "instillSecret": true, + "instillUIOrder": 0, + "title": "API key", + "type": "string" + }, + "domain": { + "description": "Your Freshdesk domain. You can find this by going to Admin -> Search for \"Portals\" -> Portal URL. Your portal URL will look like \"yourdomain.freshdesk.com\". Please only input your domain and not the whole URL.", + "instillUpstreamTypes": [ + "reference" + ], + "instillAcceptFormats": [ + "string" + ], + "instillSecret": true, + "instillUIOrder": 1, + "title": "Domain", + "type": "string" + } + }, + "required": [ + "api-key", + "domain" + ], + "instillEditOnNodeFields": [ + "api-key", + "domain" + ], + "title": "Freshdesk Connection", + "type": "object" +} diff --git a/application/freshdesk/v0/config/tasks.json b/application/freshdesk/v0/config/tasks.json new file mode 100644 index 00000000..4953d054 --- /dev/null +++ b/application/freshdesk/v0/config/tasks.json @@ -0,0 +1,2466 @@ +{ + "$defs": { + "language": { + "enum": [ + "Arabic", + "Bosnian", + "Bulgarian", + "Catalan", + "Chinese", + "Chinese (Traditional)", + "Croatian", + "Czech", + "Danish", + "Dutch", + "English", + "Estonian", + "Filipino", + "Finnish", + "French", + "German", + "Greek", + "Hebrew", + "Hungarian", + "Icelandic", + "Indonesian", + "Italian", + "Japanese", + "Korean", + "Latvian", + "Lithuanian", + "Malay", + "Norwegian", + "Polish", + "Portuguese (BR)", + "Portuguese/Portugal", + "Romanian", + "Russian", + "Serbian", + "Slovak", + "Slovenian", + "Spanish", + "Spanish (Latin America)", + "Swedish", + "Thai", + "Turkish", + "Ukrainian", + "Vietnamese" + ], + "example": "English" + }, + "time-zone": { + "enum": [ + "American Samoa", + "International Date Line West", + "Midway Island", + "Hawaii", + "Alaska", + "Pacific Time (US & Canada)", + "Tijuana", + "Arizona", + "Mazatlan", + "Mountain Time (US & Canada)", + "Central America", + "Central Time (US & Canada)", + "Chihuahua", + "Guadalajara", + "Mexico City", + "Monterrey", + "Saskatchewan", + "Bogota", + "Eastern Time (US & Canada)", + "Indiana (East)", + "Lima", + "Quito", + "Atlantic Time (Canada)", + "Caracas", + "Georgetown", + "La Paz", + "Santiago", + "Newfoundland", + "Brasilia", + "Buenos Aires", + "Montevideo", + "Greenland", + "Mid-Atlantic", + "Azores", + "Cape Verde Is.", + "Casablanca", + "Dublin", + "Edinburgh", + "Lisbon", + "London", + "Monrovia", + "UTC", + "Amsterdam", + "Belgrade", + "Berlin", + "Bern", + "Bratislava", + "Brussels", + "Budapest", + "Copenhagen", + "Ljubljana", + "Madrid", + "Paris", + "Prague", + "Rome", + "Sarajevo", + "Skopje", + "Stockholm", + "Vienna", + "Warsaw", + "West Central Africa", + "Zagreb", + "Athens", + "Bucharest", + "Cairo", + "Harare", + "Helsinki", + "Jerusalem", + "Kaliningrad", + "Kyiv", + "Pretoria", + "Riga", + "Sofia", + "Tallinn", + "Vilnius", + "Baghdad", + "Istanbul", + "Kuwait", + "Minsk", + "Moscow", + "Nairobi", + "Riyadh", + "St. Petersburg", + "Volgograd", + "Tehran", + "Abu Dhabi", + "Baku", + "Muscat", + "Samara", + "Tbilisi", + "Yerevan", + "Kabul", + "Ekaterinburg", + "Islamabad", + "Karachi", + "Tashkent", + "Chennai", + "Kolkata", + "Mumbai", + "New Delhi", + "Sri Jayawardenepura", + "Kathmandu", + "Almaty", + "Astana", + "Dhaka", + "Urumqi", + "Rangoon", + "Bangkok", + "Hanoi", + "Jakarta", + "Krasnoyarsk", + "Novosibirsk", + "Beijing", + "Chongqing", + "Hong Kong", + "Irkutsk", + "Kuala Lumpur", + "Perth", + "Singapore", + "Taipei", + "Ulaanbaatar", + "Osaka", + "Sapporo", + "Seoul", + "Tokyo", + "Yakutsk", + "Adelaide", + "Darwin", + "Brisbane", + "Canberra", + "Guam", + "Hobart", + "Melbourne", + "Port Moresby", + "Sydney", + "Vladivostok", + "Magadan", + "New Caledonia", + "Solomon Is.", + "Srednekolymsk", + "Auckland", + "Fiji", + "Kamchatka", + "Marshall Is.", + "Wellington", + "Chatham Is.", + "Nuku'alofa", + "Samoa", + "Tokelau Is." + ], + "example": "Eastern Time (US & Canada)" + }, + "ticket": { + "ticket-id": { + "description": "The ID of the ticket", + "title": "Ticket ID", + "type": "integer" + }, + "subject": { + "description": "Subject of the ticket", + "title": "Subject", + "type": "string" + }, + "description-text": { + "description": "Content of the ticket", + "title": "Description Text", + "type": "string" + }, + "source": { + "description": "Source of the ticket. Eg: Email", + "title": "Source", + "type": "string" + }, + "status": { + "description": "Status of the ticket. Eg: Pending", + "title": "Status", + "type": "string" + }, + "priority": { + "description": "Priority of the ticket. Eg: Medium", + "title": "Priority", + "type": "string" + }, + "ticket-type": { + "description": "Used to categorize the ticket. To check the possible types a ticket can have, please go to Admin -> Ticket Fields", + "title": "Ticket Type", + "type": "string" + }, + "association-type": { + "description": "Used to determine whether a ticket is a parent, child, tracker or related ticket", + "title": "Association Type", + "type": "string" + }, + "associated-ticket-list": { + "description": "List of associated ticket IDs", + "title": "Associated Ticket List", + "type": "array" + }, + "tags": { + "description": "Tags associated with the ticket.", + "title": "Tags", + "type": "array" + }, + "cc-emails": { + "description": "Email addresses added in the 'cc' field of the incoming ticket email", + "title": "CC Emails", + "type": "array" + }, + "bcc-emails":{ + "description": "Email addresses added in the 'bcc' field of the incoming ticket email", + "title": "BCC Emails", + "type": "array" + }, + "forward-emails": { + "description": "Email addresses added while forwarding a ticket", + "title": "Forward Emails", + "type": "array" + }, + "reply-cc-emails": { + "description": "Email addresses added while replying to a ticket", + "title": "Reply CC Emails", + "type": "array" + }, + "requester-id": { + "description": "ID of the requester", + "title": "Requester ID", + "type": "integer" + }, + "responder-id": { + "description": "ID of the agent to whom the ticket has been assigned. List of agents can be found in Admin -> Agents", + "title": "Responder ID", + "type": "integer" + }, + "company-id": { + "description": "ID of the company to which this ticket belongs", + "title": "Company ID", + "type": "integer" + }, + "group-id": { + "description": "ID of the group to which the ticket has been assigned. List of groups can be found in Admin -> Groups", + "title": "Group ID", + "type": "integer" + }, + "product-id": { + "description": "ID of the product to which the ticket is associated. List of products can be found in Admin -> Multiple Products", + "title": "Product ID", + "type": "integer" + }, + "support-email": { + "description": "Support email address. You can find it in Admin -> Email (under channel).", + "title": "Support Email", + "type": "string" + }, + "to-emails": { + "description": "Email addresses to which the ticket was originally sent", + "title": "To Emails", + "type": "array" + }, + "spam": { + "description": "Set to true if the ticket is marked as spam", + "title": "Spam", + "type": "boolean" + }, + "due-by": { + "description": "Timestamp that denotes when the ticket is due to be resolved. In UTC format.", + "title": "Due By", + "type": "string" + }, + "is-escalated": { + "description": "Set to true if the ticket has been escalated", + "title": "Is Escalated", + "type": "boolean" + }, + "first-response-due-by": { + "description": "Timestamp that denotes when the first response is due. In UTC format. You can adjust this by going to Admin -> SLA policy (under Workflows).", + "title": "First Response Due By", + "type": "string" + }, + "first-response-escalated": { + "description": "Set to true if the ticket has been escalated as the result of first response time being breached", + "title": "First Response Escalated", + "type": "boolean" + }, + "next-response-due-by": { + "description": "Timestamp that denotes when the next response is due. In UTC format. You can adjust this by going to Admin -> SLA policy (under Workflows).", + "title": "Next Response Due By", + "type": "string" + }, + "next-response-escalated": { + "description": "Set to true if the ticket has been escalated as the result of next response time being breached", + "title": "Next Response Escalated", + "type": "boolean" + }, + "created-at": { + "description": "Timestamp that denotes when the ticket/conversation was created. In UTC format.", + "title": "Created At", + "type": "string" + }, + "updated-at": { + "description": "Timestamp that denotes when the ticket was last updated. In UTC format.", + "title": "Updated At", + "type": "string" + }, + "attachments": { + "description": "Ticket attachments (cannot be more than 20MB)", + "title": "Attachments", + "type": "array" + }, + "sentiment-score": { + "description": "Freshdesk uses AI to assess the emotional tone and attitude expressed in customer interaction.", + "title": "Sentiment Score", + "type": "integer" + }, + "initial-sentiment-score": { + "description": "The initial sentiment score of the ticket", + "title": "Initial Sentiment Score", + "type": "integer" + }, + "custom-fields": { + "description": "Custom fields that the ticket have. Custom fields can be created or modified in Admin -> Ticket Fields", + "title": "Custom Fields", + "type": "object" + }, + "conversation-id":{ + "description": "The ID of the note or reply that is associated with the ticket", + "title": "Conversation ID", + "type": "integer" + } + }, + "contact": { + "contact-id": { + "description": "ID of the contact", + "title": "Contact ID", + "type": "integer" + }, + "name": { + "description": "Name of the contact", + "title": "Name", + "type": "string" + }, + "email": { + "description": "The primary email address of the contact", + "title": "Email", + "type": "string" + }, + "phone": { + "description": "Telephone number of the contact", + "title": "Phone", + "type": "string" + }, + "mobile": { + "description": "Mobile number of the contact", + "title": "Mobile", + "type": "string" + }, + "description": { + "description": "Description of the contact", + "title": "Description", + "type": "string" + }, + "address": { + "description": "Address of the contact", + "title": "Address", + "type": "string" + }, + "job-title": { + "description": "Job title of the contact", + "title": "Job Title", + "type": "string" + }, + "tags": { + "description": "Tags associated with the contact", + "title": "Tags", + "type": "array" + }, + "language": { + "description": "Language of the contact", + "title": "Language", + "type": "string" + }, + "time-zone": { + "description": "Time zone of the contact", + "title": "Time Zone", + "type": "string" + }, + "company-id": { + "description": "ID of the primary company to which the contact belongs", + "title": "Company ID", + "type": "integer" + }, + "unique-external-id": { + "description": "Unique external ID of the contact which be assigned by the user(agent)", + "title": "Unique External ID", + "type": "string" + }, + "twitter-id": { + "description": "Twitter ID of the contact", + "title": "Twitter ID", + "type": "string" + }, + "view-all-tickets": { + "description": "Set to true if the contact can see all the tickets that are associated with the primary company.", + "title": "View All Tickets", + "type": "boolean" + }, + "deleted": { + "description": "Set to true if the contact is deleted", + "title": "Deleted", + "type": "boolean" + }, + "active": { + "description": "Set to true if the contact has been verified", + "title": "Active", + "type": "boolean" + }, + "other-emails": { + "description": "List of other email addresses of the contact", + "title": "Other Emails", + "type": "array" + }, + "other-companies": { + "description": "List of other companies to which the contact belongs", + "title": "Other Companies", + "type": "array" + }, + "other-phone-numbers": { + "description": "List of other phone numbers of the contact", + "title": "Other Phone Numbers", + "type": "array" + }, + "created-at": { + "description": "Timestamp that denotes when the contact was created. In UTC format.", + "title": "Created At", + "type": "string" + }, + "updated-at": { + "description": "Timestamp that denotes when the contact was last updated. In UTC format.", + "title": "Updated At", + "type": "string" + }, + "custom-fields": { + "description": "Custom fields that the contact have. Custom fields can be created or modified in Admin -> Customer Fields", + "title": "Custom Fields", + "type": "object" + } + }, + "company": { + "company-id": { + "description": "ID of the company", + "title": "Company ID", + "type": "integer" + }, + "name": { + "description": "Name of the company", + "title": "Name", + "type": "string" + }, + "description": { + "description": "Description of the company", + "title": "Description", + "type": "string" + }, + "note": { + "description": "Note about the company", + "title": "Note", + "type": "string" + }, + "domains": { + "description": "Domains of the company", + "title": "Domains", + "type": "array" + }, + "health-score": { + "description": "The strength of your relationship with the company. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: \"At risk\", \"Doing okay\", \"Happy\"", + "title": "Health Score", + "type": "string" + }, + "account-tier": { + "description": "Classification based on how much value the company brings to your business. To look at all the possible values or create custom values, please go to Admin -> Customer Fields. Default values: \"Basic\", \"Premium\", \"Enterprise\"", + "title": "Account Tier", + "type": "string" + }, + "renewal-date": { + "description": "Date when your contract or relationship with the company is due for renewal", + "title": "Renewal Date", + "type": "string" + }, + "industry": { + "description": "The industry in which the company operates. To look at all the possible values or create custom values, please go to Admin -> Customer Fields.", + "title": "Industry", + "type": "string" + }, + "created-at": { + "description": "Timestamp that denotes when the company was created. In UTC format.", + "title": "Created At", + "type": "string" + }, + "updated-at": { + "description": "Timestamp that denotes when the company was last updated. In UTC format.", + "title": "Updated At", + "type": "string" + }, + "custom-fields": { + "description": "Custom fields that the company have. Custom fields can be created or modified in Admin -> Customer Fields", + "title": "Custom Fields", + "type": "object" + } + } + }, + "TASK_GET_TICKET": { + "instillShortDescription": "Get ticket using ID", + "input": { + "description": "Ticket ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["ticket-id"], + "properties": { + "ticket-id": { + "$ref": "#/$defs/ticket/ticket-id", + "instillAcceptFormats": ["integer"], + "instillUpstreamTypes": ["value", "reference"], + "instillUIMultiline": false, + "instillUIOrder": 0 + } + }, + "required": ["ticket-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Ticket information", + "instillUIOrder": 0, + "properties": { + "subject": { + "$ref": "#/$defs/ticket/subject", + "instillFormat": "string", + "instillUIOrder": 0 + }, + "description-text": { + "$ref": "#/$defs/ticket/description-text", + "instillFormat": "string", + "instillUIOrder": 1 + }, + "source": { + "$ref": "#/$defs/ticket/source", + "instillFormat": "string", + "instillUIOrder": 2 + }, + "status": { + "$ref": "#/$defs/ticket/status", + "instillFormat": "string", + "instillUIOrder": 3 + }, + "priority": { + "$ref": "#/$defs/ticket/priority", + "instillFormat": "string", + "instillUIOrder": 4 + }, + "ticket-type": { + "$ref": "#/$defs/ticket/ticket-type", + "instillFormat": "string", + "instillUIOrder": 5 + }, + "association-type": { + "$ref": "#/$defs/ticket/association-type", + "instillFormat": "string", + "instillUIOrder": 6 + }, + "associated-ticket-list": { + "$ref": "#/$defs/ticket/associated-ticket-list", + "instillFormat": "array:integer", + "items": { + "title": "Associated Ticket", + "type": "integer", + "description": "The ID of the ticket associated with the current ticket", + "instillFormat": "integer" + }, + "instillUIOrder": 7 + }, + "tags": { + "$ref": "#/$defs/ticket/tags", + "instillFormat": "array:string", + "items": { + "title": "Tag", + "type": "string", + "description": "Tag associated with the ticket", + "instillFormat": "string" + }, + "instillUIOrder": 8 + }, + "cc-emails": { + "$ref": "#/$defs/ticket/cc-emails", + "instillFormat": "array:string", + "items": { + "title": "CC Email", + "type": "string", + "description": "One of the email address added in the 'cc' field of the incoming ticket email", + "instillFormat": "string" + }, + "instillUIOrder": 9 + }, + "forward-emails": { + "$ref": "#/$defs/ticket/forward-emails", + "instillFormat": "array:string", + "items": { + "title": "Forward Email", + "type": "string", + "description": "One of the email address added while forwarding a ticket", + "instillFormat": "string" + }, + "instillUIOrder": 10 + }, + "reply-cc-emails": { + "$ref": "#/$defs/ticket/reply-cc-emails", + "instillFormat": "array:string", + "items": { + "title": "Reply CC Email", + "type": "string", + "description": "One of the email address added while replying to a ticket", + "instillFormat": "string" + }, + "instillUIOrder": 11 + }, + "requester-id": { + "$ref": "#/$defs/ticket/requester-id", + "instillFormat": "integer", + "instillUIOrder": 12 + }, + "responder-id": { + "$ref": "#/$defs/ticket/responder-id", + "instillFormat": "integer", + "instillUIOrder": 13 + }, + "company-id": { + "$ref": "#/$defs/ticket/company-id", + "instillFormat": "integer", + "instillUIOrder": 14 + }, + "group-id": { + "$ref": "#/$defs/ticket/group-id", + "instillFormat": "integer", + "instillUIOrder": 15 + }, + "product-id": { + "$ref": "#/$defs/ticket/product-id", + "instillFormat": "integer", + "instillUIOrder": 16 + }, + "support-email": { + "$ref": "#/$defs/ticket/support-email", + "instillFormat": "string", + "instillUIOrder": 17 + }, + "to-emails": { + "$ref": "#/$defs/ticket/to-emails", + "instillFormat": "array:string", + "items": { + "title": "To Email", + "type": "string", + "description": "One of the email address to which the ticket was originally sent", + "instillFormat": "string" + }, + "instillUIOrder": 18 + }, + "spam": { + "$ref": "#/$defs/ticket/spam", + "instillFormat": "boolean", + "instillUIOrder": 19 + }, + "due-by": { + "$ref": "#/$defs/ticket/due-by", + "instillFormat": "string", + "instillUIOrder": 20 + }, + "is-escalated": { + "$ref": "#/$defs/ticket/is-escalated", + "instillFormat": "boolean", + "instillUIOrder": 21 + }, + "first-response-due-by": { + "$ref": "#/$defs/ticket/first-response-due-by", + "instillFormat": "string", + "instillUIOrder": 22 + }, + "first-response-escalated": { + "$ref": "#/$defs/ticket/first-response-escalated", + "instillFormat": "boolean", + "instillUIOrder": 23 + }, + "next-response-due-by": { + "$ref": "#/$defs/ticket/next-response-due-by", + "instillFormat": "string", + "instillUIOrder": 24 + }, + "next-response-escalated": { + "$ref": "#/$defs/ticket/next-response-escalated", + "instillFormat": "boolean", + "instillUIOrder": 25 + }, + "created-at": { + "$ref": "#/$defs/ticket/created-at", + "instillFormat": "string", + "instillUIOrder": 26 + }, + "updated-at": { + "$ref": "#/$defs/ticket/updated-at", + "instillFormat": "string", + "instillUIOrder": 27 + }, + "attachments": { + "$ref": "#/$defs/ticket/attachments", + "instillFormat": "array", + "items": { + "title": "Attachment", + "type": "object", + "properties": { + "name": { + "description": "The name of the file", + "instillFormat": "string", + "instillUIOrder": 0, + "title": "Attachment Name", + "type": "string" + }, + "content-type": { + "description": "The type of the file", + "instillFormat": "string", + "instillUIOrder": 1, + "title": "Attachment Content Type", + "type": "string" + }, + "url": { + "description": "The URL to the attachment.", + "instillFormat": "string", + "instillUIOrder": 2, + "title": "Attachment URL", + "type": "string" + } + }, + "required": ["name", "content-type", "url"] + }, + "instillUIOrder": 28 + }, + "sentiment-score": { + "$ref": "#/$defs/ticket/sentiment-score", + "instillFormat": "integer", + "instillUIOrder": 29 + }, + "initial-sentiment-score": { + "$ref": "#/$defs/ticket/initial-sentiment-score", + "instillFormat": "integer", + "instillUIOrder": 30 + }, + "custom-fields": { + "$ref": "#/$defs/ticket/custom-fields", + "instillFormat": "semi-structured/json", + "required": [], + "instillUIOrder": 31 + } + }, + "required": [ + "requester-id", + "subject", + "description-text", + "source", + "status", + "priority", + "created-at", + "updated-at" + ], + "title": "Output", + "type": "object" + } + }, + "TASK_CREATE_TICKET": { + "instillShortDescription": "Create ticket", + "input": { + "description": "Ticket Information", + "instillUIOrder": 0, + "instillEditOnNodeFields": [ + "requester-id", + "email", + "subject", + "description", + "source", + "status", + "priority" + ], + "properties": { + "requester-id": { + "description": "ID of the requester. Must be an existing contact. If you fill in this field, you don't need to fill in the email field. Only one of the two fields is required.", + "title": "Requester ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "email": { + "description": "Email address of the requester. If you fill in the Requester ID above, it will be ignored. Only one of the two fields is required. If no contact exists with this email address in Freshdesk, it will be added as a new contact.", + "title": "Email", + "type": "string", + "instillUIOrder": 1, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "subject": { + "$ref": "#/$defs/ticket/subject", + "instillUIOrder": 2, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "description": { + "description": "Content of the ticket. You can use HTML tags in the content.", + "title": "Description", + "type": "string", + "instillUIOrder": 3, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "source": { + "$ref": "#/$defs/ticket/source", + "enum": [ + "Email", + "Portal", + "Phone", + "Twitter", + "Facebook", + "Chat", + "Feedback Widget", + "Outbound Email", + "Ecommerce" + ], + "example": "Portal", + "instillUIOrder": 4, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "status": { + "$ref": "#/$defs/ticket/status", + "enum": [ + "Open", + "Pending", + "Resolved", + "Closed", + "Waiting on Customer", + "Waiting on Third Party" + ], + "example": "Open", + "instillUIOrder": 5, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "priority": { + "$ref": "#/$defs/ticket/priority", + "enum": ["Low", "Medium", "High", "Urgent"], + "example": "Low", + "instillUIOrder": 6, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "ticket-type": { + "$ref": "#/$defs/ticket/ticket-type", + "instillUIOrder": 7, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "company-id": { + "$ref": "#/$defs/ticket/company-id", + "instillUIOrder": 8, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "product-id": { + "$ref": "#/$defs/ticket/product-id", + "instillUIOrder": 9, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "group-id": { + "$ref": "#/$defs/ticket/group-id", + "instillUIOrder": 10, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "responder-id": { + "$ref": "#/$defs/ticket/responder-id", + "instillUIOrder": 11, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "tags": { + "$ref": "#/$defs/ticket/tags", + "instillUIOrder": 12, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "cc-emails": { + "$ref": "#/$defs/ticket/cc-emails", + "instillUIOrder": 13, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "parent-id": { + "description": "ID of the parent ticket. Need to be filled out if you want to create a child ticket.", + "title": "Parent ID", + "type": "integer", + "instillUIOrder": 14, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "related-ticket-ids": { + "description": "List of related ticket IDs. Need to be filled out if you want to create a tracker ticket.", + "title": "Related Ticket IDs", + "type": "array", + "instillUIOrder": 15, + "instillAcceptFormats": ["array:integer"], + "items": { + "type": "integer" + }, + "instillUpstreamTypes": ["value", "reference"] + } + }, + "required": ["subject", "description", "source", "status", "priority"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Ticket ID and create date", + "instillUIOrder": 0, + "properties": { + "ticket-id": { + "$ref": "#/$defs/ticket/ticket-id", + "instillFormat": "integer", + "instillUIOrder": 0 + }, + "created-at": { + "$ref": "#/$defs/ticket/created-at", + "instillFormat": "string", + "instillUIOrder": 1 + } + }, + "required": ["ticket-id", "created-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_REPLY_TO_TICKET": { + "instillShortDescription": "Reply to a ticket thread.", + "input": { + "description": "Reply information", + "instillUIOrder": 0, + "instillEditOnNodeFields": [ + "ticket-id", + "body", + "from-email", + "user-id", + "cc-emails", + "bcc-emails" + ], + "properties": { + "ticket-id":{ + "$ref": "#/$defs/ticket/ticket-id", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "body": { + "description": "Content of the reply. Can be in HTML format.", + "title": "Body", + "type": "string", + "instillUIOrder": 0, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "from-email": { + "description": "Email address that is replying to the ticket. You need to have this email address registered in Freshdesk by going to Admin -> Emails. If you leave this field empty, the global support email will be used.", + "title": "From Email", + "type": "string", + "instillUIOrder": 1, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "user-id": { + "description": "ID of the agent/contact replying to the ticket. If you fill this field using a contact ID, there will be no email sent to the requester.", + "title": "User ID", + "type": "integer", + "instillUIOrder": 2, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "cc-emails": { + "description": "Email addresses added in the 'cc' field of the outgoing ticket email.", + "title": "CC Emails", + "type": "array", + "instillUIOrder": 3, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "bcc-emails": { + "description": "Email addresses added in the 'bcc' field of the outgoing ticket email.", + "title": "BCC Emails", + "type": "array", + "instillUIOrder": 4, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["ticket-id","body"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Conversation ID, Ticket ID and created date", + "instillUIOrder": 0, + "properties": { + "conversation-id": { + "$ref": "#/$defs/ticket/conversation-id", + "instillFormat": "integer", + "instillUIOrder": 0 + }, + "created-at": { + "$ref": "#/$defs/ticket/created-at", + "instillFormat": "string", + "instillUIOrder": 1 + } + }, + "required": ["conversation-id","created-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_CREATE_TICKET_NOTE": { + "instillShortDescription": "Create a private/public note on a ticket thread.", + "input": { + "description": "Note information", + "instillUIOrder": 0, + "instillEditOnNodeFields": [ + "ticket-id", + "body", + "notify-emails", + "user-id", + "private", + "incoming" + ], + "properties": { + "ticket-id":{ + "$ref": "#/$defs/ticket/ticket-id", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "body": { + "description": "Content of the note. Can be in HTML format.", + "title": "Body", + "type": "string", + "instillUIOrder": 1, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "notify-emails": { + "description": "Email addresses of agents/users who need to be notified about this note. The emails need to exist in Freshdesk agent. Agent list can be seen in Admin -> Agents.", + "title": "Notify Emails", + "type": "array", + "instillUIOrder": 2, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "user-id": { + "description": "ID of the agent/contact who is adding the note.", + "title": "User ID", + "type": "integer", + "instillUIOrder": 3, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "private":{ + "description": "Set to true if the note is private", + "title": "Private", + "type": "boolean", + "instillUIOrder": 4, + "instillAcceptFormats": ["boolean"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "incoming":{ + "description": "Set to true if a particular note should appear as being created from outside (i.e., not through web portal).", + "title": "Incoming", + "type": "boolean", + "instillUIOrder": 5, + "instillAcceptFormats": ["boolean"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + + }, + "required": ["ticket-id","body"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Conversation ID, Ticket ID and created date", + "instillUIOrder": 0, + "properties": { + "conversation-id": { + "$ref": "#/$defs/ticket/conversation-id", + "instillFormat": "integer", + "instillUIOrder": 0 + }, + "created-at": { + "$ref": "#/$defs/ticket/created-at", + "instillFormat": "string", + "instillUIOrder": 1 + } + }, + "required": ["conversation-id","created-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_ALL_CONVERSATIONS":{ + "instillShortDescription": "Get all the conversations in a ticket. (Conversations are replies and notes that are added to a ticket)", + "input": { + "description": "Ticket ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": [ + "ticket-id" + ], + "properties": { + "ticket-id":{ + "description": "Ticket ID", + "title": "Ticket ID", + "type": "integer", + "instillUIOrder": 2, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["ticket-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Conversations", + "instillUIOrder": 0, + "properties": { + "conversations": { + "description": "An array of conversations", + "instillUIOrder": 0, + "title": "Conversations", + "type": "array", + "items": { + "title": "Conversation", + "type": "object", + "properties": { + "body-text":{ + "description": "Content of the conversation", + "title": "Body Text", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "conversation-id":{ + "$ref": "#/$defs/ticket/conversation-id", + "instillUIOrder": 1, + "instillFormat":"integer" + }, + "support-email":{ + "$ref": "#/$defs/ticket/support-email", + "instillUIOrder": 2, + "instillFormat":"string" + }, + "to-emails":{ + "description": "Email addresses of agents/users who need to be notified about this conversation", + "title": "To Emails", + "type": "array", + "instillUIOrder": 3, + "instillFormat":"array:string", + "items": { + "title": "To Email", + "type": "string", + "description": "One of the email addresses of agents/users who need to be notified about this conversation", + "instillFormat": "string" + } + }, + "from-email":{ + "description": "Email address that is replying to the ticket or adding the note.", + "title": "From Email", + "type": "string", + "instillUIOrder": 4, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "cc-emails":{ + "$ref": "#/$defs/ticket/cc-emails", + "instillUIOrder": 5, + "instillFormat":"array:string", + "items": { + "title": "CC Email", + "type": "string", + "description": "One of the email address added in the 'cc' field of the incoming ticket email", + "instillFormat": "string" + } + }, + "bcc-emails":{ + "$ref": "#/$defs/ticket/bcc-emails", + "instillUIOrder": 6, + "instillFormat":"array:string", + "items": { + "title": "BCC Email", + "type": "string", + "description": "One of the email address added in the 'bcc' field of the incoming ticket email", + "instillFormat": "string" + } + }, + "incoming":{ + "description": "Set to true if a particular conversation should appear as being created from outside", + "title": "Incoming", + "type": "boolean", + "instillUIOrder": 7, + "instillFormat":"boolean" + }, + "private":{ + "description": "Set to true if a note is private. Can be set only for notes.", + "title": "Incoming", + "type": "boolean", + "instillUIOrder": 8, + "instillFormat":"boolean" + }, + "user-id":{ + "description": "ID of the agent/contact replying to the ticket.", + "title": "Incoming", + "type": "integer", + "instillUIOrder": 9, + "instillFormat":"integer" + }, + "created-at":{ + "$ref": "#/$defs/ticket/created-at", + "instillUIOrder": 10, + "instillFormat":"string" + } + }, + "required": [ + "body-text", + "created-at" + ] + } + }, + "conversations-length":{ + "description": "Number of conversations", + "title": "Conversations Length", + "type": "integer", + "instillUIOrder": 1, + "instillFormat":"integer" + } + }, + "required": ["conversations", "conversations-length"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_CONTACT": { + "instillShortDescription": "Get contact using ID", + "input": { + "description": "Contact ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["contact-id"], + "properties": { + "contact-id": { + "$ref": "#/$defs/contact/contact-id", + "instillAcceptFormats": ["integer"], + "instillUpstreamTypes": ["value", "reference"], + "instillUIMultiline": false, + "instillUIOrder": 0 + } + }, + "required": ["contact-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Contact information", + "instillUIOrder": 0, + "properties": { + "name": { + "$ref": "#/$defs/contact/name", + "instillFormat": "string", + "instillUIOrder": 0 + }, + "email": { + "$ref": "#/$defs/contact/email", + "instillFormat": "string", + "instillUIOrder": 1 + }, + "phone": { + "$ref": "#/$defs/contact/phone", + "instillFormat": "string", + "instillUIOrder": 2 + }, + "mobile": { + "$ref": "#/$defs/contact/mobile", + "instillFormat": "string", + "instillUIOrder": 3 + }, + "description": { + "$ref": "#/$defs/contact/description", + "instillFormat": "string", + "instillUIOrder": 4 + }, + "address": { + "$ref": "#/$defs/contact/address", + "instillFormat": "string", + "instillUIOrder": 5 + }, + "job-title": { + "$ref": "#/$defs/contact/job-title", + "instillFormat": "string", + "instillUIOrder": 6 + }, + "tags": { + "$ref": "#/$defs/contact/tags", + "instillFormat": "array:string", + "items": { + "title": "Tag", + "type": "string", + "description": "Tag associated with the contact", + "instillFormat": "string" + }, + "instillUIOrder": 7 + }, + "language": { + "$ref": "#/$defs/contact/language", + "instillFormat": "string", + "instillUIOrder": 8 + }, + "time-zone": { + "$ref": "#/$defs/contact/time-zone", + "instillFormat": "string", + "instillUIOrder": 9 + }, + "company-id": { + "$ref": "#/$defs/contact/company-id", + "instillFormat": "integer", + "instillUIOrder": 10 + }, + "unique-external-id": { + "$ref": "#/$defs/contact/unique-external-id", + "instillFormat": "string", + "instillUIOrder": 11 + }, + "twitter-id": { + "$ref": "#/$defs/contact/twitter-id", + "instillFormat": "string", + "instillUIOrder": 12 + }, + "view-all-tickets": { + "$ref": "#/$defs/contact/view-all-tickets", + "instillFormat": "boolean", + "instillUIOrder": 13 + }, + "deleted": { + "$ref": "#/$defs/contact/deleted", + "instillFormat": "boolean", + "instillUIOrder": 14 + }, + "active": { + "$ref": "#/$defs/contact/active", + "instillFormat": "boolean", + "instillUIOrder": 15 + }, + "other-emails": { + "$ref": "#/$defs/contact/other-emails", + "instillFormat": "array:string", + "items": { + "title": "Other Email", + "type": "string", + "description": "The other email addresses of the contact", + "instillFormat": "string" + }, + "instillUIOrder": 16 + }, + "other-companies": { + "$ref": "#/$defs/contact/other-companies", + "instillFormat": "array", + "items": { + "title": "Company", + "type": "object", + "properties": { + "company-id": { + "description": "ID of the company", + "instillFormat": "integer", + "instillUIOrder": 0, + "title": "Company ID", + "type": "integer" + }, + "view-all-tickets": { + "description": "Set to true if the contact can see all the tickets that are associated with the company.", + "instillFormat": "boolean", + "instillUIOrder": 1, + "title": "View All Tickets", + "type": "boolean" + } + }, + "required": ["company-id", "view-all-tickets"] + }, + "instillUIOrder": 17 + }, + "other-phone-numbers": { + "$ref": "#/$defs/contact/other-phone-numbers", + "instillFormat": "array:string", + "items": { + "title": "Other Phone Number", + "type": "string", + "description": "The other phone number of the contact", + "instillFormat": "string" + }, + "instillUIOrder": 18 + }, + "created-at": { + "$ref": "#/$defs/contact/created-at", + "instillFormat": "string", + "instillUIOrder": 19 + }, + "updated-at": { + "$ref": "#/$defs/contact/updated-at", + "instillFormat": "string", + "instillUIOrder": 20 + }, + "custom-fields": { + "$ref": "#/$defs/contact/custom-fields", + "instillFormat": "semi-structured/json", + "required": [], + "instillUIOrder": 21 + } + }, + "required": ["name"], + "title": "Output", + "type": "object" + } + }, + "TASK_CREATE_CONTACT": { + "instillShortDescription": "Create contact", + "input": { + "description": "Contact Information", + "instillUIOrder": 0, + "instillEditOnNodeFields": [ + "name", + "email", + "phone", + "mobile", + "description", + "language", + "time-zone" + ], + "properties": { + "name": { + "$ref": "#/$defs/contact/name", + "instillUIOrder": 0, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "email": { + "$ref": "#/$defs/contact/email", + "instillUIOrder": 1, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "phone": { + "$ref": "#/$defs/contact/phone", + "instillUIOrder": 2, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "mobile": { + "$ref": "#/$defs/contact/mobile", + "instillUIOrder": 3, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "description": { + "$ref": "#/$defs/contact/description", + "instillUIOrder": 4, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "address": { + "$ref": "#/$defs/contact/address", + "instillUIOrder": 5, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "job-title": { + "$ref": "#/$defs/contact/job-title", + "instillUIOrder": 6, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "tags": { + "$ref": "#/$defs/contact/tags", + "instillUIOrder": 7, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "language": { + "description": "Language of the contact", + "title": "Language", + "type": "string", + "$ref": "#/$defs/language", + "instillUIOrder": 8, + "instillAcceptFormats": ["string"], + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "time-zone": { + "description": "Time zone of the contact", + "title": "Time Zone", + "type": "string", + "$ref": "#/$defs/time-zone", + "instillUIOrder": 9, + "instillAcceptFormats": ["string"], + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "company-id": { + "$ref": "#/$defs/contact/company-id", + "instillUIOrder": 10, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "reference"] + }, + "unique-external-id": { + "$ref": "#/$defs/contact/unique-external-id", + "instillUIOrder": 11, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "twitter-id": { + "$ref": "#/$defs/contact/twitter-id", + "instillUIOrder": 12, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "view-all-tickets": { + "description": "Used to determine if the contact can see all the tickets that are associated with the primary company. Note: this property will be ignored if the Company ID is not provided.", + "title": "View All Tickets", + "type": "boolean", + "instillUIOrder": 13, + "instillAcceptFormats": ["boolean"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "other-emails": { + "$ref": "#/$defs/contact/other-emails", + "instillUIOrder": 14, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "other-companies": { + "title": "Other Companies", + "type": "array", + "description": "List of other companies to which the contact belongs. Each company should be in the format of company-id;view-all-tickets(boolean \"true\"/\"false\") Example: 123;true", + "items": { + "type": "string" + }, + "instillUIOrder": 15, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "other-phone-numbers": { + "$ref": "#/$defs/contact/other-phone-numbers", + "instillUIOrder": 16, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["name"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Contact ID and create date", + "instillUIOrder": 0, + "properties": { + "contact-id": { + "$ref": "#/$defs/contact/contact-id", + "instillFormat": "integer", + "instillUIOrder": 0 + }, + "created-at": { + "$ref": "#/$defs/contact/created-at", + "instillFormat": "string", + "instillUIOrder": 1 + } + }, + "required": ["contact-id", "created-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_COMPANY": { + "instillShortDescription": "Get company using ID", + "input": { + "description": "Company ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["company-id"], + "properties": { + "company-id": { + "$ref": "#/$defs/contact/company-id", + "instillAcceptFormats": ["integer"], + "instillUpstreamTypes": ["value", "reference"], + "instillUIMultiline": false, + "instillUIOrder": 0 + } + }, + "required": ["company-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Company information", + "instillUIOrder": 0, + "properties": { + "name": { + "$ref": "#/$defs/company/name", + "instillFormat": "string", + "instillUIOrder": 0 + }, + "description": { + "$ref": "#/$defs/company/description", + "instillFormat": "string", + "instillUIOrder": 1 + }, + "note": { + "$ref": "#/$defs/company/note", + "instillFormat": "string", + "instillUIOrder": 2 + }, + "domains": { + "$ref": "#/$defs/company/domains", + "instillFormat": "array:string", + "items": { + "title": "Domain", + "type": "string", + "description": "Domain of the company", + "instillFormat": "string" + }, + "instillUIOrder": 3 + }, + "health-score": { + "$ref": "#/$defs/company/health-score", + "instillFormat": "string", + "instillUIOrder": 4 + }, + "account-tier": { + "$ref": "#/$defs/company/account-tier", + "instillFormat": "string", + "instillUIOrder": 5 + }, + "renewal-date": { + "$ref": "#/$defs/company/renewal-date", + "instillFormat": "string", + "instillUIOrder": 6 + }, + "industry": { + "$ref": "#/$defs/company/industry", + "instillFormat": "string", + "instillUIOrder": 7 + }, + "created-at": { + "$ref": "#/$defs/company/created-at", + "instillFormat": "string", + "instillUIOrder": 8 + }, + "updated-at": { + "$ref": "#/$defs/company/updated-at", + "instillFormat": "string", + "instillUIOrder": 9 + }, + "custom-fields": { + "$ref": "#/$defs/company/custom-fields", + "instillFormat": "semi-structured/json", + "required": [], + "instillUIOrder": 10 + } + }, + "required": ["name","created-at","updated-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_CREATE_COMPANY": { + "instillShortDescription": "Create company", + "input": { + "description": "Company Information", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["name", "description", "note", "domains"], + "properties": { + "name": { + "$ref": "#/$defs/company/name", + "instillUIOrder": 0, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "description": { + "$ref": "#/$defs/company/description", + "instillUIOrder": 1, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "note": { + "$ref": "#/$defs/company/note", + "instillUIOrder": 2, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "domains": { + "$ref": "#/$defs/company/domains", + "instillUIOrder": 3, + "instillAcceptFormats": ["array:string"], + "items": { + "type": "string" + }, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "health-score": { + "$ref": "#/$defs/company/health-score", + "instillUIOrder": 4, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "account-tier": { + "$ref": "#/$defs/company/account-tier", + "instillUIOrder": 5, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "renewal-date": { + "description": "Date when your contract or relationship with the company is due for renewal. Enter in the format YYYY-MM-DD.", + "title": "Renewal Date", + "type": "string", + "instillUIOrder": 6, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "industry": { + "$ref": "#/$defs/company/industry", + "instillUIOrder": 7, + "instillAcceptFormats": ["string"], + "instillUIMultiline": true, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["name"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Company ID and create date", + "instillUIOrder": 0, + "properties": { + "company-id": { + "$ref": "#/$defs/company/company-id", + "instillFormat": "integer", + "instillUIOrder": 0 + }, + "created-at": { + "$ref": "#/$defs/company/created-at", + "instillFormat": "string", + "instillUIOrder": 1 + } + }, + "required": ["company-id", "created-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_ALL": { + "instillShortDescription": "Task to get all the IDs of existing contacts, companies, tickets, products, agents, roles, or skills. Note: products, agents, roles, and skills require admin privileges. Some of these might not work, depending on the plan you are on.", + "input": { + "description": "Object type", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["object-type", "length"], + "properties": { + "object-type": { + "description": "Type of object to get IDs for", + "title": "Object Type", + "type": "string", + "enum": ["Contacts", "Companies", "Tickets", "Products", "Agents", "Roles" , "Skills"], + "instillUIOrder": 0, + "instillAcceptFormats": ["string"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + }, + "length":{ + "description": "The maximum number of IDs allowed is 500. The most recent IDs will be retrieved.", + "default": 500, + "title": "Length", + "type": "integer", + "instillUIOrder": 1, + "instillFormat":"integer", + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["object-type", "length"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "IDs of the object", + "instillUIOrder": 0, + "properties": { + "ids": { + "description": "List of IDs", + "title": "IDs", + "type": "array", + "items": { + "title": "ID", + "type": "integer", + "description": "ID of the object", + "instillFormat": "integer" + }, + "instillFormat": "array:integer", + "instillUIOrder": 0 + }, + "id-length": { + "description": "Number of IDs", + "title": "ID Length", + "type": "integer", + "instillFormat": "integer", + "instillUIOrder": 1 + } + }, + "required": ["ids", "id-length"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_PRODUCT":{ + "instillShortDescription": "Get product using ID. This task will only work if you have admin privileges.", + "input": { + "description": "Product ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["product-id"], + "properties": { + "product-id":{ + "description": "Product ID", + "title": "Product ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["product-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Product information", + "instillUIOrder": 0, + "properties": { + "name":{ + "description": "Name of the product", + "title": "Name", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "description":{ + "description": "Description of the product", + "title": "Description", + "type": "string", + "instillUIOrder": 1, + "instillFormat":"string" + }, + "primary-email":{ + "description": "Primary email of the product", + "title": "Primary Email", + "type": "string", + "instillUIOrder": 2, + "instillFormat":"string" + }, + "created-at":{ + "description": "Timestamp that denotes when the product was created", + "title": "Created At", + "type": "string", + "instillUIOrder": 3, + "instillFormat":"string" + }, + "updated-at":{ + "description": "Timestamp that denotes when the product was last updated", + "title": "Updated At", + "type": "string", + "instillUIOrder": 4, + "instillFormat":"string" + }, + "default":{ + "description": "Set to true if the product is the default product", + "title": "Default", + "type": "boolean", + "instillUIOrder": 5, + "instillFormat":"boolean" + } + }, + "required": ["name","description","primary-email","created-at","updated-at","default"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_AGENT":{ + "instillShortDescription": "Get agent using ID. This task will only work if you have admin privileges. Agents are those in your team who will login to Freshdesk.", + "input": { + "description": "Agent ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["agent-id"], + "properties": { + "agent-id":{ + "description": "Agent ID", + "title": "Agent ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["agent-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Agent information", + "instillUIOrder": 0, + "properties": { + "name":{ + "description": "Name of the agent", + "title": "Name", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "active":{ + "description": "Set to true if the agent is verified", + "title": "Active", + "type": "boolean", + "instillUIOrder": 1, + "instillFormat":"boolean" + }, + "email":{ + "description": "Email of the agent", + "title": "Email", + "type": "string", + "instillUIOrder": 2, + "instillFormat":"string" + }, + "job-title":{ + "description": "Job title of the agent", + "title": "Job Title", + "type": "string", + "instillUIOrder": 3, + "instillFormat":"string" + }, + "language":{ + "description": "Language of the agent", + "title": "Language", + "type": "string", + "instillUIOrder": 4, + "instillFormat":"string" + }, + "mobile":{ + "description": "Mobile number of the agent", + "title": "Mobile", + "type": "string", + "instillUIOrder": 5, + "instillFormat":"string" + }, + "phone":{ + "description": "Telephone number of the agent", + "title": "Phone", + "type": "string", + "instillUIOrder": 6, + "instillFormat":"string" + }, + "time-zone":{ + "description": "Time zone of the agent", + "title": "Time Zone", + "type": "string", + "instillUIOrder": 7, + "instillFormat":"string" + }, + "type":{ + "description": "Type of the agent. Can be \"Support Agent\", \"Field Agent\" or \"Collaborator\"", + "title": "Type", + "type": "string", + "instillUIOrder": 8, + "instillFormat":"string" + }, + "ticket-scope":{ + "description": "Ticket permission of the agent. Can be \"Global Access\", \"Group Access\" or \"Restricted Access\"", + "title": "Ticket Scope", + "type": "string", + "instillUIOrder": 9, + "instillFormat":"string" + }, + "available":{ + "description": "Set to true if the agent is in a group that has enabled \"Automatic Ticket Assignment\"", + "title": "Available", + "type": "boolean", + "instillUIOrder": 10, + "instillFormat":"boolean" + }, + "group-ids":{ + "description": "Group IDs of the agent", + "title": "Group IDs", + "type": "array", + "instillUIOrder": 11, + "instillFormat":"array:integer", + "items": { + "title": "Group ID", + "type": "integer", + "description": "ID of the group", + "instillFormat": "integer" + } + }, + "role-ids":{ + "description": "Role IDs of the agent", + "title": "Role IDs", + "type": "array", + "instillUIOrder": 12, + "instillFormat":"array:integer", + "items": { + "title": "Role ID", + "type": "integer", + "description": "ID of the role", + "instillFormat": "integer" + } + }, + "skill-ids":{ + "description": "Skill IDs of the agent", + "title": "Skill IDs", + "type": "array", + "instillUIOrder": 13, + "instillFormat":"array:integer", + "items": { + "title": "Skill ID", + "type": "integer", + "description": "ID of the skill", + "instillFormat": "integer" + } + }, + "occasional":{ + "description": "Set to true if the agent is not working full-time", + "title": "Occasional", + "type": "boolean", + "instillUIOrder": 14, + "instillFormat":"boolean" + }, + "signature":{ + "description": "Signature of the agent in HTML format", + "title": "Signature", + "type": "string", + "instillUIOrder": 15, + "instillFormat":"string" + }, + "focus-mode":{ + "description": "Set to true if the agent is in focus mode", + "title": "Focus Mode", + "type": "boolean", + "instillUIOrder": 16, + "instillFormat":"boolean" + }, + "deactivated":{ + "description": "Set to true if the agent is deactivated", + "title": "Deactivated", + "type": "boolean", + "instillUIOrder": 17, + "instillFormat":"boolean" + }, + "created-at":{ + "description": "Timestamp that denotes when the agent was created", + "title": "Created At", + "type": "string", + "instillUIOrder": 18, + "instillFormat":"string" + }, + "updated-at":{ + "description": "Timestamp that denotes when the agent was last updated", + "title": "Updated At", + "type": "string", + "instillUIOrder": 19, + "instillFormat":"string" + } + }, + "required": ["email", "type", "ticket-scope", "occasional"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_ROLE":{ + "instillShortDescription": "Get role using ID. This task will only work if you have admin privileges. Roles allow agents/collaborators to have different privileges.", + "input": { + "description": "Role ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["role-id"], + "properties": { + "role-id":{ + "description": "Role ID", + "title": "Role ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["role-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Role information", + "instillUIOrder": 0, + "properties": { + "name":{ + "description": "Name of the role", + "title": "Name", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "description":{ + "description": "Description of the role", + "title": "Description", + "type": "string", + "instillUIOrder": 1, + "instillFormat":"string" + }, + "default":{ + "description": "Set to true if the role is the default role", + "title": "Default", + "type": "boolean", + "instillUIOrder": 2, + "instillFormat":"boolean" + }, + "agent-type":{ + "description": "Type of the agent. Can be \"Support Agent\", \"Field Agent\" or \"Collaborator\"", + "title": "Agent Type", + "type": "string", + "instillUIOrder": 3, + "instillFormat":"string" + }, + "created-at":{ + "description": "Timestamp that denotes when the role was created", + "title": "Created At", + "type": "string", + "instillUIOrder": 4, + "instillFormat":"string" + }, + "updated-at":{ + "description": "Timestamp that denotes when the role was last updated", + "title": "Updated At", + "type": "string", + "instillUIOrder": 5, + "instillFormat":"string" + } + }, + "required": ["name","description","default","agent-type","created-at","updated-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_GROUP":{ + "instillShortDescription": "Get group using ID. This task will only work if you have admin privileges. Agents can be classified into groups such as Customer Support.", + "input": { + "description": "Group ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["group-id"], + "properties": { + "group-id":{ + "description": "Group ID", + "title": "Group ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["group-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Group information", + "instillUIOrder": 0, + "properties": { + "name":{ + "description": "Name of the group", + "title": "Name", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "description":{ + "description": "Description of the group", + "title": "Description", + "type": "string", + "instillUIOrder": 1, + "instillFormat":"string" + }, + "agent-ids":{ + "description": "Agent IDs of the group", + "title": "Agent IDs", + "type": "array", + "instillUIOrder": 2, + "instillFormat":"array:integer", + "items": { + "title": "Agent ID", + "type": "integer", + "description": "ID of the agent", + "instillFormat": "integer" + } + }, + "auto-ticket-assign":{ + "description": "The type of automatic ticket assignment set for the group.", + "title": "Auto Ticket Assign", + "type": "string", + "instillUIOrder": 3, + "instillFormat":"string" + }, + "escalate-to":{ + "description": "The ID of the user to whom an escalation email is sent if a ticket is unassigned.", + "title": "Escalate To", + "type": "integer", + "instillUIOrder": 4, + "instillFormat":"integer" + }, + "unassigned-duration":{ + "description": "The duration for which a ticket is unassigned before it is escalated.", + "title": "Unassigned Duration", + "type": "string", + "instillUIOrder": 5, + "instillFormat":"string" + }, + "group-type":{ + "description": "Group type. Can be \"support_agent_group\" or \"field_agent_group\"", + "title": "Group Type", + "type": "string", + "instillUIOrder": 6, + "instillFormat":"string" + }, + "agent-availability-status":{ + "description": "The availability status of the agent in the group. Automatically set to true if the group has enabled \"Automatic Ticket Assignment\".", + "title": "Agent Availability Status", + "type": "boolean", + "instillUIOrder": 7, + "instillFormat":"boolean" + }, + "created-at":{ + "description": "Timestamp that denotes when the group was created", + "title": "Created At", + "type": "string", + "instillUIOrder": 8, + "instillFormat":"string" + }, + "updated-at":{ + "description": "Timestamp that denotes when the group was last updated", + "title": "Updated At", + "type": "string", + "instillUIOrder": 9, + "instillFormat":"string" + } + }, + "required": ["name","description","auto-ticket-assign", "created-at","updated-at"], + "title": "Output", + "type": "object" + } + }, + "TASK_GET_SKILL":{ + "instillShortDescription": "Get skill using ID. This task will only work if you have admin privileges. Agents can be assigned skills, and it is possible for tickets to be automatically assigned to agents based on the skills they have.", + "input": { + "description": "Skill ID", + "instillUIOrder": 0, + "instillEditOnNodeFields": ["skill-id"], + "properties": { + "skill-id":{ + "description": "Skill ID", + "title": "Skill ID", + "type": "integer", + "instillUIOrder": 0, + "instillAcceptFormats": ["integer"], + "instillUIMultiline": false, + "instillUpstreamTypes": ["value", "template", "reference"] + } + }, + "required": ["skill-id"], + "title": "Input", + "type": "object" + }, + "output": { + "description": "Skill information", + "instillUIOrder": 0, + "properties": { + "name":{ + "description": "Name of the skill", + "title": "Name", + "type": "string", + "instillUIOrder": 0, + "instillFormat":"string" + }, + "rank":{ + "description": "Rank of the skill", + "title": "Rank", + "type": "integer", + "instillUIOrder": 1, + "instillFormat":"integer" + }, + "condition-match-type":{ + "description": "Type of condition match. Can be \"all\" or \"any\"", + "title": "Condition Match Type", + "type": "string", + "instillUIOrder": 2, + "instillFormat":"string" + }, + "conditions":{ + "description": "Conditions for the skill", + "title": "Conditions", + "instillFormat": "array:semi-structured/json", + "type": "array", + "items":{ + "title": "Condition", + "instillFormat": "semi-structured/json" + }, + "instillUIOrder": 3 + }, + "created-at":{ + "description": "Timestamp that denotes when the skill was created", + "title": "Created At", + "type": "string", + "instillUIOrder": 4, + "instillFormat":"string" + }, + "updated-at":{ + "description": "Timestamp that denotes when the skill was last updated", + "title": "Updated At", + "type": "string", + "instillUIOrder": 5, + "instillFormat":"string" + } + }, + "required": ["name","rank","condition-match-type","conditions","created-at","updated-at"], + "title": "Output", + "type": "object" + } + } +} diff --git a/application/freshdesk/v0/contact.go b/application/freshdesk/v0/contact.go new file mode 100644 index 00000000..5404d3ed --- /dev/null +++ b/application/freshdesk/v0/contact.go @@ -0,0 +1,319 @@ +package freshdesk + +import ( + "fmt" + "strconv" + "strings" + + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +// name, email, phone, mobile, description, job_title, tags, language, time_zone, company_id, unique_external_id, twitter_id, view_all_tickets, deletedc, other_companies, created_at, updated_at + +const ( + ContactPath = "contacts" +) + +// API functions for Contact + +func (c *FreshdeskClient) GetContact(contactID int64) (*TaskGetContactResponse, error) { + resp := &TaskGetContactResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", ContactPath, contactID)); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) CreateContact(req *TaskCreateContactReq) (*TaskCreateContactResponse, error) { + resp := &TaskCreateContactResponse{} + + httpReq := c.httpclient.R().SetBody(req).SetResult(resp) + if _, err := httpReq.Post("/" + ContactPath); err != nil { + return nil, err + } + return resp, nil + +} + +// Task 1: Get Contact + +type TaskGetContactInput struct { + ContactID int64 `json:"contact-id"` +} + +type TaskGetContactResponse struct { + Name string `json:"name"` + Email string `json:"email"` + Phone string `json:"phone"` + Mobile string `json:"mobile"` + Description string `json:"description"` + Address string `json:"address"` + JobTitle string `json:"job_title"` + Tags []string `json:"tags"` + Language string `json:"language"` + TimeZone string `json:"time_zone"` + CompanyID int64 `json:"company_id"` + UniqueExternalID string `json:"unique_external_id"` + TwitterID string `json:"twitter_id"` + ViewAllTickets bool `json:"view_all_tickets"` + Deleted bool `json:"deleted"` + Active bool `json:"active"` + OtherEmails []string `json:"other_emails"` + OtherCompanies []taskGetContactResponseOtherCompany `json:"other_companies"` + OtherPhoneNumbers []taskGetContactResponseOtherPhoneNumber `json:"other_phone_numbers"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + CustomFields map[string]interface{} `json:"custom_fields"` +} + +type taskGetContactResponseOtherCompany struct { + CompanyID int64 `json:"company_id"` + ViewAllTickets bool `json:"view_all_tickets"` +} + +type taskGetContactResponseOtherPhoneNumber struct { + PhoneNumber string `json:"value"` +} + +type TaskGetContactOutput struct { + Name string `json:"name"` + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + Mobile string `json:"mobile,omitempty"` + Description string `json:"description,omitempty"` + Address string `json:"address,omitempty"` + JobTitle string `json:"job-title,omitempty"` + Tags []string `json:"tags"` + Language string `json:"language,omitempty"` + TimeZone string `json:"time-zone,omitempty"` + CompanyID int64 `json:"company-id,omitempty"` + UniqueExternalID string `json:"unique-external-id,omitempty"` + TwitterID string `json:"twitter-id,omitempty"` + ViewAllTickets bool `json:"view-all-tickets"` + Deleted bool `json:"deleted"` + Active bool `json:"active"` + OtherEmails []string `json:"other-emails"` + OtherCompaniesIDs []taskGetContactOutputOtherCompany `json:"other-companies-ids,omitempty"` + OtherPhoneNumbers []string `json:"other-phone-numbers"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` + CustomFields map[string]interface{} `json:"custom-fields,omitempty"` +} + +type taskGetContactOutputOtherCompany struct { + CompanyID int64 `json:"company-id"` + ViewAllTickets bool `json:"view-all-tickets"` +} + +func (e *execution) TaskGetContact(in *structpb.Struct) (*structpb.Struct, error) { + + inputStruct := TaskGetContactInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetContact(inputStruct.ContactID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetContactOutput{ + Name: resp.Name, + Email: resp.Email, + Phone: resp.Phone, + Mobile: resp.Mobile, + Description: resp.Description, + Address: resp.Address, + JobTitle: resp.JobTitle, + Tags: resp.Tags, + Language: convertCodeToLanguage(resp.Language), + TimeZone: resp.TimeZone, + CompanyID: resp.CompanyID, + UniqueExternalID: resp.UniqueExternalID, + TwitterID: resp.TwitterID, + ViewAllTickets: resp.ViewAllTickets, + Deleted: resp.Deleted, + Active: resp.Active, + OtherEmails: *checkForNilString(&resp.OtherEmails), + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + } + + if len(resp.OtherCompanies) > 0 { + outputStruct.OtherCompaniesIDs = make([]taskGetContactOutputOtherCompany, len(resp.OtherCompanies)) + for index, company := range resp.OtherCompanies { + outputStruct.OtherCompaniesIDs[index].CompanyID = company.CompanyID + outputStruct.OtherCompaniesIDs[index].ViewAllTickets = company.ViewAllTickets + } + } + + if len(resp.OtherPhoneNumbers) > 0 { + outputStruct.OtherPhoneNumbers = make([]string, len(resp.OtherPhoneNumbers)) + for index, phone := range resp.OtherPhoneNumbers { + outputStruct.OtherPhoneNumbers[index] = phone.PhoneNumber + } + } else { + outputStruct.OtherPhoneNumbers = []string{} + } + + if len(resp.CustomFields) > 0 { + outputStruct.CustomFields = resp.CustomFields + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 2: Create Contact + +type TaskCreateContactInput struct { + Name string `json:"name"` + Email string `json:"email"` + Phone string `json:"phone"` + Mobile string `json:"mobile"` + Description string `json:"description"` + Address string `json:"address"` + JobTitle string `json:"job-title"` + Tags []string `json:"tags"` + Language string `json:"language"` + TimeZone string `json:"time-zone"` + CompanyID int64 `json:"company-id"` + UniqueExternalID string `json:"unique-external-id"` + TwitterID string `json:"twitter-id"` + ViewAllTickets bool `json:"view-all-tickets"` + OtherEmails []string `json:"other-emails"` + OtherCompanies []string `json:"other-companies"` + OtherPhoneNumbers []string `json:"other-phone-numbers"` +} + +type TaskCreateContactReq struct { + Name string `json:"name"` + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + Mobile string `json:"mobile,omitempty"` + Description string `json:"description,omitempty"` + Address string `json:"address,omitempty"` + JobTitle string `json:"job_title,omitempty"` + Tags []string `json:"tags,omitempty"` + Language string `json:"language,omitempty"` + TimeZone string `json:"time_zone,omitempty"` + CompanyID int64 `json:"company_id,omitempty"` + UniqueExternalID string `json:"unique_external_id,omitempty"` + TwitterID string `json:"twitter_id,omitempty"` + ViewAllTickets bool `json:"view_all_tickets,omitempty"` + OtherEmails []string `json:"other_emails,omitempty"` + OtherCompanies []taskCreateContactReqOtherCompany `json:"other_companies,omitempty"` + OtherPhoneNumbers []taskCreateContactReqOtherPhoneNumber `json:"other_phone_numbers,omitempty"` +} + +type taskCreateContactReqOtherCompany struct { + CompanyID int64 `json:"company_id"` + ViewAllTickets bool `json:"view_all_tickets"` +} + +type taskCreateContactReqOtherPhoneNumber struct { + PhoneNumber string `json:"value"` +} + +type TaskCreateContactResponse struct { + ID int64 `json:"id"` + CreatedAt string `json:"created_at"` +} + +type TaskCreateContactOutput struct { + ID int64 `json:"contact-id"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskCreateContact(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskCreateContactInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + if inputStruct.Email == "" && inputStruct.Phone == "" && inputStruct.Mobile == "" { + return nil, fmt.Errorf("please fill in at least one of the following fields: email, phone, mobile") + } + + req := TaskCreateContactReq{ + Name: inputStruct.Name, + Email: inputStruct.Email, + Phone: inputStruct.Phone, + Mobile: inputStruct.Mobile, + Description: inputStruct.Description, + Address: inputStruct.Address, + JobTitle: inputStruct.JobTitle, + Tags: inputStruct.Tags, + Language: convertLanguageToCode(inputStruct.Language), + TimeZone: inputStruct.TimeZone, + CompanyID: inputStruct.CompanyID, + UniqueExternalID: inputStruct.UniqueExternalID, + TwitterID: inputStruct.TwitterID, + ViewAllTickets: inputStruct.ViewAllTickets, + OtherEmails: inputStruct.OtherEmails, + } + + if len(inputStruct.OtherCompanies) > 0 { + req.OtherCompanies = make([]taskCreateContactReqOtherCompany, len(inputStruct.OtherCompanies)) + for index, company := range inputStruct.OtherCompanies { + // input format for other companies: company_id;view_all_tickets + + otherCompanyInfo := strings.Split(company, ";") + if len(otherCompanyInfo) != 2 { + return nil, fmt.Errorf("invalid format. The correct format is company_id;view_all_tickets(boolean \"true\"/\"false\"). Example: 123;true") + } + + req.OtherCompanies[index].CompanyID, err = strconv.ParseInt(otherCompanyInfo[0], 10, 64) + + if err != nil { + return nil, fmt.Errorf("error converting string to int64: %v", err) + } + + if otherCompanyInfo[1] != "true" && otherCompanyInfo[1] != "false" { + return nil, fmt.Errorf("invalid value for view_all_tickets. Please use either \"true\" or \"false\" Correct format: company_id;view_all_tickets(boolean \"true\"/\"false\"). Example: 123;true") + } + + req.OtherCompanies[index].ViewAllTickets = otherCompanyInfo[1] == "true" + + } + } + + if len(inputStruct.OtherPhoneNumbers) > 0 { + req.OtherPhoneNumbers = make([]taskCreateContactReqOtherPhoneNumber, len(inputStruct.OtherPhoneNumbers)) + for index, phone := range inputStruct.OtherPhoneNumbers { + req.OtherPhoneNumbers[index].PhoneNumber = phone + } + } + + resp, err := e.client.CreateContact(&req) + + if err != nil { + return nil, err + } + + outputStruct := TaskCreateContactOutput{ + ID: resp.ID, + CreatedAt: convertTimestampResp(resp.CreatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, err + } + + return output, nil +} diff --git a/application/freshdesk/v0/contact_test.go b/application/freshdesk/v0/contact_test.go new file mode 100644 index 00000000..2ecc575f --- /dev/null +++ b/application/freshdesk/v0/contact_test.go @@ -0,0 +1,194 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +func TestComponent_ExecuteGetContactTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetContactMock. + When(154023114559). + Then( + &TaskGetContactResponse{ + Name: "Fake Contact", + Email: "matt.rogers@freshdesk.com", + TimeZone: "Casablanca", + CompanyID: 154001113950, + ViewAllTickets: false, + Language: "en", + Active: true, + CreatedAt: "2024-08-18T03:48:03Z", + UpdatedAt: "2024-08-22T06:51:54Z", + }, nil) + + tc := struct { + name string + input TaskGetContactInput + wantOutput TaskGetContactOutput + }{ + name: "ok - task get contact", + input: TaskGetContactInput{ + ContactID: 154023114559, + }, + wantOutput: TaskGetContactOutput{ + Name: "Fake Contact", + Email: "matt.rogers@freshdesk.com", + TimeZone: "Casablanca", + CompanyID: 154001113950, + ViewAllTickets: false, + Language: "English", + Active: true, + CreatedAt: "2024-08-18 03:48:03 UTC", + UpdatedAt: "2024-08-22 06:51:54 UTC", + OtherEmails: []string{}, + OtherPhoneNumbers: []string{}, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetContact}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetContact + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteCreateContactTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.CreateContactMock. + When( + &TaskCreateContactReq{ + Name: "New Contact", + Email: "newcontact@gmail.com", + Phone: "1234567890", + Description: "New Contact Description", + Address: "New Contact Address", + JobTitle: "New Contact Job Title", + Tags: []string{"tag1", "tag2"}, + Language: "zh-TW", + TimeZone: "Taipei", + ViewAllTickets: false, + CompanyID: 154001113950, + OtherCompanies: []taskCreateContactReqOtherCompany{ + { + CompanyID: 154001162614, + ViewAllTickets: true, + }, + }, + OtherEmails: []string{"otherrandomemail@gmail.com"}, + }). + Then(&TaskCreateContactResponse{ + ID: 154023626050, + CreatedAt: "2024-08-29T06:24:40Z", + }, nil) + + tc := struct { + name string + input TaskCreateContactInput + wantOutput TaskCreateContactOutput + }{ + name: "ok - task create contact", + input: TaskCreateContactInput{ + Name: "New Contact", + Email: "newcontact@gmail.com", + Phone: "1234567890", + Description: "New Contact Description", + Address: "New Contact Address", + JobTitle: "New Contact Job Title", + Tags: []string{"tag1", "tag2"}, + Language: "Chinese (Traditional)", + TimeZone: "Taipei", + ViewAllTickets: false, + CompanyID: 154001113950, + OtherCompanies: []string{"154001162614;true"}, + OtherEmails: []string{"otherrandomemail@gmail.com"}, + }, + wantOutput: TaskCreateContactOutput{ + ID: 154023626050, + CreatedAt: "2024-08-29 06:24:40 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskCreateContact}, + client: FreshdeskClientMock, + } + e.execute = e.TaskCreateContact + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/application/freshdesk/v0/freshdesk_interface_mock_test.go b/application/freshdesk/v0/freshdesk_interface_mock_test.go new file mode 100644 index 00000000..a2604b99 --- /dev/null +++ b/application/freshdesk/v0/freshdesk_interface_mock_test.go @@ -0,0 +1,4805 @@ +// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT. + +package freshdesk + +//go:generate minimock -i github.com/instill-ai/component/application/freshdesk/v0.FreshdeskInterface -o freshdesk_interface_mock_test.go -n FreshdeskInterfaceMock -p freshdesk + +import ( + "sync" + mm_atomic "sync/atomic" + mm_time "time" + + "github.com/gojuno/minimock/v3" +) + +// FreshdeskInterfaceMock implements FreshdeskInterface +type FreshdeskInterfaceMock struct { + t minimock.Tester + finishOnce sync.Once + + funcCreateCompany func(req *TaskCreateCompanyReq) (tp1 *TaskCreateCompanyResponse, err error) + inspectFuncCreateCompany func(req *TaskCreateCompanyReq) + afterCreateCompanyCounter uint64 + beforeCreateCompanyCounter uint64 + CreateCompanyMock mFreshdeskInterfaceMockCreateCompany + + funcCreateContact func(req *TaskCreateContactReq) (tp1 *TaskCreateContactResponse, err error) + inspectFuncCreateContact func(req *TaskCreateContactReq) + afterCreateContactCounter uint64 + beforeCreateContactCounter uint64 + CreateContactMock mFreshdeskInterfaceMockCreateContact + + funcCreateTicket func(req *TaskCreateTicketReq) (tp1 *TaskCreateTicketResponse, err error) + inspectFuncCreateTicket func(req *TaskCreateTicketReq) + afterCreateTicketCounter uint64 + beforeCreateTicketCounter uint64 + CreateTicketMock mFreshdeskInterfaceMockCreateTicket + + funcCreateTicketNote func(ticketID int64, req *TaskCreateTicketNoteReq) (tp1 *TaskCreateTicketNoteResponse, err error) + inspectFuncCreateTicketNote func(ticketID int64, req *TaskCreateTicketNoteReq) + afterCreateTicketNoteCounter uint64 + beforeCreateTicketNoteCounter uint64 + CreateTicketNoteMock mFreshdeskInterfaceMockCreateTicketNote + + funcGetAgent func(agentID int64) (tp1 *TaskGetAgentResponse, err error) + inspectFuncGetAgent func(agentID int64) + afterGetAgentCounter uint64 + beforeGetAgentCounter uint64 + GetAgentMock mFreshdeskInterfaceMockGetAgent + + funcGetAll func(objectType string, pagination bool, paginationPath string) (ta1 []TaskGetAllResponse, s1 string, err error) + inspectFuncGetAll func(objectType string, pagination bool, paginationPath string) + afterGetAllCounter uint64 + beforeGetAllCounter uint64 + GetAllMock mFreshdeskInterfaceMockGetAll + + funcGetAllConversations func(ticketID int64, pagination bool, paginationPath string) (ta1 []TaskGetAllConversationsResponse, s1 string, err error) + inspectFuncGetAllConversations func(ticketID int64, pagination bool, paginationPath string) + afterGetAllConversationsCounter uint64 + beforeGetAllConversationsCounter uint64 + GetAllConversationsMock mFreshdeskInterfaceMockGetAllConversations + + funcGetCompany func(companyID int64) (tp1 *TaskGetCompanyResponse, err error) + inspectFuncGetCompany func(companyID int64) + afterGetCompanyCounter uint64 + beforeGetCompanyCounter uint64 + GetCompanyMock mFreshdeskInterfaceMockGetCompany + + funcGetContact func(contactID int64) (tp1 *TaskGetContactResponse, err error) + inspectFuncGetContact func(contactID int64) + afterGetContactCounter uint64 + beforeGetContactCounter uint64 + GetContactMock mFreshdeskInterfaceMockGetContact + + funcGetGroup func(groupID int64) (tp1 *TaskGetGroupResponse, err error) + inspectFuncGetGroup func(groupID int64) + afterGetGroupCounter uint64 + beforeGetGroupCounter uint64 + GetGroupMock mFreshdeskInterfaceMockGetGroup + + funcGetProduct func(productID int64) (tp1 *TaskGetProductResponse, err error) + inspectFuncGetProduct func(productID int64) + afterGetProductCounter uint64 + beforeGetProductCounter uint64 + GetProductMock mFreshdeskInterfaceMockGetProduct + + funcGetRole func(roleID int64) (tp1 *TaskGetRoleResponse, err error) + inspectFuncGetRole func(roleID int64) + afterGetRoleCounter uint64 + beforeGetRoleCounter uint64 + GetRoleMock mFreshdeskInterfaceMockGetRole + + funcGetSkill func(skillID int64) (tp1 *TaskGetSkillResponse, err error) + inspectFuncGetSkill func(skillID int64) + afterGetSkillCounter uint64 + beforeGetSkillCounter uint64 + GetSkillMock mFreshdeskInterfaceMockGetSkill + + funcGetTicket func(ticketID int64) (tp1 *TaskGetTicketResponse, err error) + inspectFuncGetTicket func(ticketID int64) + afterGetTicketCounter uint64 + beforeGetTicketCounter uint64 + GetTicketMock mFreshdeskInterfaceMockGetTicket + + funcReplyToTicket func(ticketID int64, req *TaskReplyToTicketReq) (tp1 *TaskReplyToTicketResponse, err error) + inspectFuncReplyToTicket func(ticketID int64, req *TaskReplyToTicketReq) + afterReplyToTicketCounter uint64 + beforeReplyToTicketCounter uint64 + ReplyToTicketMock mFreshdeskInterfaceMockReplyToTicket +} + +// NewFreshdeskInterfaceMock returns a mock for FreshdeskInterface +func NewFreshdeskInterfaceMock(t minimock.Tester) *FreshdeskInterfaceMock { + m := &FreshdeskInterfaceMock{t: t} + + if controller, ok := t.(minimock.MockController); ok { + controller.RegisterMocker(m) + } + + m.CreateCompanyMock = mFreshdeskInterfaceMockCreateCompany{mock: m} + m.CreateCompanyMock.callArgs = []*FreshdeskInterfaceMockCreateCompanyParams{} + + m.CreateContactMock = mFreshdeskInterfaceMockCreateContact{mock: m} + m.CreateContactMock.callArgs = []*FreshdeskInterfaceMockCreateContactParams{} + + m.CreateTicketMock = mFreshdeskInterfaceMockCreateTicket{mock: m} + m.CreateTicketMock.callArgs = []*FreshdeskInterfaceMockCreateTicketParams{} + + m.CreateTicketNoteMock = mFreshdeskInterfaceMockCreateTicketNote{mock: m} + m.CreateTicketNoteMock.callArgs = []*FreshdeskInterfaceMockCreateTicketNoteParams{} + + m.GetAgentMock = mFreshdeskInterfaceMockGetAgent{mock: m} + m.GetAgentMock.callArgs = []*FreshdeskInterfaceMockGetAgentParams{} + + m.GetAllMock = mFreshdeskInterfaceMockGetAll{mock: m} + m.GetAllMock.callArgs = []*FreshdeskInterfaceMockGetAllParams{} + + m.GetAllConversationsMock = mFreshdeskInterfaceMockGetAllConversations{mock: m} + m.GetAllConversationsMock.callArgs = []*FreshdeskInterfaceMockGetAllConversationsParams{} + + m.GetCompanyMock = mFreshdeskInterfaceMockGetCompany{mock: m} + m.GetCompanyMock.callArgs = []*FreshdeskInterfaceMockGetCompanyParams{} + + m.GetContactMock = mFreshdeskInterfaceMockGetContact{mock: m} + m.GetContactMock.callArgs = []*FreshdeskInterfaceMockGetContactParams{} + + m.GetGroupMock = mFreshdeskInterfaceMockGetGroup{mock: m} + m.GetGroupMock.callArgs = []*FreshdeskInterfaceMockGetGroupParams{} + + m.GetProductMock = mFreshdeskInterfaceMockGetProduct{mock: m} + m.GetProductMock.callArgs = []*FreshdeskInterfaceMockGetProductParams{} + + m.GetRoleMock = mFreshdeskInterfaceMockGetRole{mock: m} + m.GetRoleMock.callArgs = []*FreshdeskInterfaceMockGetRoleParams{} + + m.GetSkillMock = mFreshdeskInterfaceMockGetSkill{mock: m} + m.GetSkillMock.callArgs = []*FreshdeskInterfaceMockGetSkillParams{} + + m.GetTicketMock = mFreshdeskInterfaceMockGetTicket{mock: m} + m.GetTicketMock.callArgs = []*FreshdeskInterfaceMockGetTicketParams{} + + m.ReplyToTicketMock = mFreshdeskInterfaceMockReplyToTicket{mock: m} + m.ReplyToTicketMock.callArgs = []*FreshdeskInterfaceMockReplyToTicketParams{} + + t.Cleanup(m.MinimockFinish) + + return m +} + +type mFreshdeskInterfaceMockCreateCompany struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockCreateCompanyExpectation + expectations []*FreshdeskInterfaceMockCreateCompanyExpectation + + callArgs []*FreshdeskInterfaceMockCreateCompanyParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockCreateCompanyExpectation specifies expectation struct of the FreshdeskInterface.CreateCompany +type FreshdeskInterfaceMockCreateCompanyExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockCreateCompanyParams + paramPtrs *FreshdeskInterfaceMockCreateCompanyParamPtrs + results *FreshdeskInterfaceMockCreateCompanyResults + Counter uint64 +} + +// FreshdeskInterfaceMockCreateCompanyParams contains parameters of the FreshdeskInterface.CreateCompany +type FreshdeskInterfaceMockCreateCompanyParams struct { + req *TaskCreateCompanyReq +} + +// FreshdeskInterfaceMockCreateCompanyParamPtrs contains pointers to parameters of the FreshdeskInterface.CreateCompany +type FreshdeskInterfaceMockCreateCompanyParamPtrs struct { + req **TaskCreateCompanyReq +} + +// FreshdeskInterfaceMockCreateCompanyResults contains results of the FreshdeskInterface.CreateCompany +type FreshdeskInterfaceMockCreateCompanyResults struct { + tp1 *TaskCreateCompanyResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Optional() *mFreshdeskInterfaceMockCreateCompany { + mmCreateCompany.optional = true + return mmCreateCompany +} + +// Expect sets up expected params for FreshdeskInterface.CreateCompany +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Expect(req *TaskCreateCompanyReq) *mFreshdeskInterfaceMockCreateCompany { + if mmCreateCompany.mock.funcCreateCompany != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by Set") + } + + if mmCreateCompany.defaultExpectation == nil { + mmCreateCompany.defaultExpectation = &FreshdeskInterfaceMockCreateCompanyExpectation{} + } + + if mmCreateCompany.defaultExpectation.paramPtrs != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by ExpectParams functions") + } + + mmCreateCompany.defaultExpectation.params = &FreshdeskInterfaceMockCreateCompanyParams{req} + for _, e := range mmCreateCompany.expectations { + if minimock.Equal(e.params, mmCreateCompany.defaultExpectation.params) { + mmCreateCompany.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateCompany.defaultExpectation.params) + } + } + + return mmCreateCompany +} + +// ExpectReqParam1 sets up expected param req for FreshdeskInterface.CreateCompany +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) ExpectReqParam1(req *TaskCreateCompanyReq) *mFreshdeskInterfaceMockCreateCompany { + if mmCreateCompany.mock.funcCreateCompany != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by Set") + } + + if mmCreateCompany.defaultExpectation == nil { + mmCreateCompany.defaultExpectation = &FreshdeskInterfaceMockCreateCompanyExpectation{} + } + + if mmCreateCompany.defaultExpectation.params != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by Expect") + } + + if mmCreateCompany.defaultExpectation.paramPtrs == nil { + mmCreateCompany.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockCreateCompanyParamPtrs{} + } + mmCreateCompany.defaultExpectation.paramPtrs.req = &req + + return mmCreateCompany +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.CreateCompany +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Inspect(f func(req *TaskCreateCompanyReq)) *mFreshdeskInterfaceMockCreateCompany { + if mmCreateCompany.mock.inspectFuncCreateCompany != nil { + mmCreateCompany.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.CreateCompany") + } + + mmCreateCompany.mock.inspectFuncCreateCompany = f + + return mmCreateCompany +} + +// Return sets up results that will be returned by FreshdeskInterface.CreateCompany +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Return(tp1 *TaskCreateCompanyResponse, err error) *FreshdeskInterfaceMock { + if mmCreateCompany.mock.funcCreateCompany != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by Set") + } + + if mmCreateCompany.defaultExpectation == nil { + mmCreateCompany.defaultExpectation = &FreshdeskInterfaceMockCreateCompanyExpectation{mock: mmCreateCompany.mock} + } + mmCreateCompany.defaultExpectation.results = &FreshdeskInterfaceMockCreateCompanyResults{tp1, err} + return mmCreateCompany.mock +} + +// Set uses given function f to mock the FreshdeskInterface.CreateCompany method +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Set(f func(req *TaskCreateCompanyReq) (tp1 *TaskCreateCompanyResponse, err error)) *FreshdeskInterfaceMock { + if mmCreateCompany.defaultExpectation != nil { + mmCreateCompany.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.CreateCompany method") + } + + if len(mmCreateCompany.expectations) > 0 { + mmCreateCompany.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.CreateCompany method") + } + + mmCreateCompany.mock.funcCreateCompany = f + return mmCreateCompany.mock +} + +// When sets expectation for the FreshdeskInterface.CreateCompany which will trigger the result defined by the following +// Then helper +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) When(req *TaskCreateCompanyReq) *FreshdeskInterfaceMockCreateCompanyExpectation { + if mmCreateCompany.mock.funcCreateCompany != nil { + mmCreateCompany.mock.t.Fatalf("FreshdeskInterfaceMock.CreateCompany mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockCreateCompanyExpectation{ + mock: mmCreateCompany.mock, + params: &FreshdeskInterfaceMockCreateCompanyParams{req}, + } + mmCreateCompany.expectations = append(mmCreateCompany.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.CreateCompany return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockCreateCompanyExpectation) Then(tp1 *TaskCreateCompanyResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockCreateCompanyResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.CreateCompany should be invoked +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Times(n uint64) *mFreshdeskInterfaceMockCreateCompany { + if n == 0 { + mmCreateCompany.mock.t.Fatalf("Times of FreshdeskInterfaceMock.CreateCompany mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateCompany.expectedInvocations, n) + return mmCreateCompany +} + +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) invocationsDone() bool { + if len(mmCreateCompany.expectations) == 0 && mmCreateCompany.defaultExpectation == nil && mmCreateCompany.mock.funcCreateCompany == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateCompany.mock.afterCreateCompanyCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateCompany.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateCompany implements FreshdeskInterface +func (mmCreateCompany *FreshdeskInterfaceMock) CreateCompany(req *TaskCreateCompanyReq) (tp1 *TaskCreateCompanyResponse, err error) { + mm_atomic.AddUint64(&mmCreateCompany.beforeCreateCompanyCounter, 1) + defer mm_atomic.AddUint64(&mmCreateCompany.afterCreateCompanyCounter, 1) + + if mmCreateCompany.inspectFuncCreateCompany != nil { + mmCreateCompany.inspectFuncCreateCompany(req) + } + + mm_params := FreshdeskInterfaceMockCreateCompanyParams{req} + + // Record call args + mmCreateCompany.CreateCompanyMock.mutex.Lock() + mmCreateCompany.CreateCompanyMock.callArgs = append(mmCreateCompany.CreateCompanyMock.callArgs, &mm_params) + mmCreateCompany.CreateCompanyMock.mutex.Unlock() + + for _, e := range mmCreateCompany.CreateCompanyMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmCreateCompany.CreateCompanyMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateCompany.CreateCompanyMock.defaultExpectation.Counter, 1) + mm_want := mmCreateCompany.CreateCompanyMock.defaultExpectation.params + mm_want_ptrs := mmCreateCompany.CreateCompanyMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockCreateCompanyParams{req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmCreateCompany.t.Errorf("FreshdeskInterfaceMock.CreateCompany got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateCompany.t.Errorf("FreshdeskInterfaceMock.CreateCompany got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateCompany.CreateCompanyMock.defaultExpectation.results + if mm_results == nil { + mmCreateCompany.t.Fatal("No results are set for the FreshdeskInterfaceMock.CreateCompany") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmCreateCompany.funcCreateCompany != nil { + return mmCreateCompany.funcCreateCompany(req) + } + mmCreateCompany.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.CreateCompany. %v", req) + return +} + +// CreateCompanyAfterCounter returns a count of finished FreshdeskInterfaceMock.CreateCompany invocations +func (mmCreateCompany *FreshdeskInterfaceMock) CreateCompanyAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateCompany.afterCreateCompanyCounter) +} + +// CreateCompanyBeforeCounter returns a count of FreshdeskInterfaceMock.CreateCompany invocations +func (mmCreateCompany *FreshdeskInterfaceMock) CreateCompanyBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateCompany.beforeCreateCompanyCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.CreateCompany. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateCompany *mFreshdeskInterfaceMockCreateCompany) Calls() []*FreshdeskInterfaceMockCreateCompanyParams { + mmCreateCompany.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockCreateCompanyParams, len(mmCreateCompany.callArgs)) + copy(argCopy, mmCreateCompany.callArgs) + + mmCreateCompany.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateCompanyDone returns true if the count of the CreateCompany invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockCreateCompanyDone() bool { + if m.CreateCompanyMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateCompanyMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateCompanyMock.invocationsDone() +} + +// MinimockCreateCompanyInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockCreateCompanyInspect() { + for _, e := range m.CreateCompanyMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateCompany with params: %#v", *e.params) + } + } + + afterCreateCompanyCounter := mm_atomic.LoadUint64(&m.afterCreateCompanyCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateCompanyMock.defaultExpectation != nil && afterCreateCompanyCounter < 1 { + if m.CreateCompanyMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateCompany") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateCompany with params: %#v", *m.CreateCompanyMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateCompany != nil && afterCreateCompanyCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateCompany") + } + + if !m.CreateCompanyMock.invocationsDone() && afterCreateCompanyCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.CreateCompany but found %d calls", + mm_atomic.LoadUint64(&m.CreateCompanyMock.expectedInvocations), afterCreateCompanyCounter) + } +} + +type mFreshdeskInterfaceMockCreateContact struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockCreateContactExpectation + expectations []*FreshdeskInterfaceMockCreateContactExpectation + + callArgs []*FreshdeskInterfaceMockCreateContactParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockCreateContactExpectation specifies expectation struct of the FreshdeskInterface.CreateContact +type FreshdeskInterfaceMockCreateContactExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockCreateContactParams + paramPtrs *FreshdeskInterfaceMockCreateContactParamPtrs + results *FreshdeskInterfaceMockCreateContactResults + Counter uint64 +} + +// FreshdeskInterfaceMockCreateContactParams contains parameters of the FreshdeskInterface.CreateContact +type FreshdeskInterfaceMockCreateContactParams struct { + req *TaskCreateContactReq +} + +// FreshdeskInterfaceMockCreateContactParamPtrs contains pointers to parameters of the FreshdeskInterface.CreateContact +type FreshdeskInterfaceMockCreateContactParamPtrs struct { + req **TaskCreateContactReq +} + +// FreshdeskInterfaceMockCreateContactResults contains results of the FreshdeskInterface.CreateContact +type FreshdeskInterfaceMockCreateContactResults struct { + tp1 *TaskCreateContactResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Optional() *mFreshdeskInterfaceMockCreateContact { + mmCreateContact.optional = true + return mmCreateContact +} + +// Expect sets up expected params for FreshdeskInterface.CreateContact +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Expect(req *TaskCreateContactReq) *mFreshdeskInterfaceMockCreateContact { + if mmCreateContact.mock.funcCreateContact != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by Set") + } + + if mmCreateContact.defaultExpectation == nil { + mmCreateContact.defaultExpectation = &FreshdeskInterfaceMockCreateContactExpectation{} + } + + if mmCreateContact.defaultExpectation.paramPtrs != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by ExpectParams functions") + } + + mmCreateContact.defaultExpectation.params = &FreshdeskInterfaceMockCreateContactParams{req} + for _, e := range mmCreateContact.expectations { + if minimock.Equal(e.params, mmCreateContact.defaultExpectation.params) { + mmCreateContact.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateContact.defaultExpectation.params) + } + } + + return mmCreateContact +} + +// ExpectReqParam1 sets up expected param req for FreshdeskInterface.CreateContact +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) ExpectReqParam1(req *TaskCreateContactReq) *mFreshdeskInterfaceMockCreateContact { + if mmCreateContact.mock.funcCreateContact != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by Set") + } + + if mmCreateContact.defaultExpectation == nil { + mmCreateContact.defaultExpectation = &FreshdeskInterfaceMockCreateContactExpectation{} + } + + if mmCreateContact.defaultExpectation.params != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by Expect") + } + + if mmCreateContact.defaultExpectation.paramPtrs == nil { + mmCreateContact.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockCreateContactParamPtrs{} + } + mmCreateContact.defaultExpectation.paramPtrs.req = &req + + return mmCreateContact +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.CreateContact +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Inspect(f func(req *TaskCreateContactReq)) *mFreshdeskInterfaceMockCreateContact { + if mmCreateContact.mock.inspectFuncCreateContact != nil { + mmCreateContact.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.CreateContact") + } + + mmCreateContact.mock.inspectFuncCreateContact = f + + return mmCreateContact +} + +// Return sets up results that will be returned by FreshdeskInterface.CreateContact +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Return(tp1 *TaskCreateContactResponse, err error) *FreshdeskInterfaceMock { + if mmCreateContact.mock.funcCreateContact != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by Set") + } + + if mmCreateContact.defaultExpectation == nil { + mmCreateContact.defaultExpectation = &FreshdeskInterfaceMockCreateContactExpectation{mock: mmCreateContact.mock} + } + mmCreateContact.defaultExpectation.results = &FreshdeskInterfaceMockCreateContactResults{tp1, err} + return mmCreateContact.mock +} + +// Set uses given function f to mock the FreshdeskInterface.CreateContact method +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Set(f func(req *TaskCreateContactReq) (tp1 *TaskCreateContactResponse, err error)) *FreshdeskInterfaceMock { + if mmCreateContact.defaultExpectation != nil { + mmCreateContact.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.CreateContact method") + } + + if len(mmCreateContact.expectations) > 0 { + mmCreateContact.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.CreateContact method") + } + + mmCreateContact.mock.funcCreateContact = f + return mmCreateContact.mock +} + +// When sets expectation for the FreshdeskInterface.CreateContact which will trigger the result defined by the following +// Then helper +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) When(req *TaskCreateContactReq) *FreshdeskInterfaceMockCreateContactExpectation { + if mmCreateContact.mock.funcCreateContact != nil { + mmCreateContact.mock.t.Fatalf("FreshdeskInterfaceMock.CreateContact mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockCreateContactExpectation{ + mock: mmCreateContact.mock, + params: &FreshdeskInterfaceMockCreateContactParams{req}, + } + mmCreateContact.expectations = append(mmCreateContact.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.CreateContact return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockCreateContactExpectation) Then(tp1 *TaskCreateContactResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockCreateContactResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.CreateContact should be invoked +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Times(n uint64) *mFreshdeskInterfaceMockCreateContact { + if n == 0 { + mmCreateContact.mock.t.Fatalf("Times of FreshdeskInterfaceMock.CreateContact mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateContact.expectedInvocations, n) + return mmCreateContact +} + +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) invocationsDone() bool { + if len(mmCreateContact.expectations) == 0 && mmCreateContact.defaultExpectation == nil && mmCreateContact.mock.funcCreateContact == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateContact.mock.afterCreateContactCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateContact.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateContact implements FreshdeskInterface +func (mmCreateContact *FreshdeskInterfaceMock) CreateContact(req *TaskCreateContactReq) (tp1 *TaskCreateContactResponse, err error) { + mm_atomic.AddUint64(&mmCreateContact.beforeCreateContactCounter, 1) + defer mm_atomic.AddUint64(&mmCreateContact.afterCreateContactCounter, 1) + + if mmCreateContact.inspectFuncCreateContact != nil { + mmCreateContact.inspectFuncCreateContact(req) + } + + mm_params := FreshdeskInterfaceMockCreateContactParams{req} + + // Record call args + mmCreateContact.CreateContactMock.mutex.Lock() + mmCreateContact.CreateContactMock.callArgs = append(mmCreateContact.CreateContactMock.callArgs, &mm_params) + mmCreateContact.CreateContactMock.mutex.Unlock() + + for _, e := range mmCreateContact.CreateContactMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmCreateContact.CreateContactMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateContact.CreateContactMock.defaultExpectation.Counter, 1) + mm_want := mmCreateContact.CreateContactMock.defaultExpectation.params + mm_want_ptrs := mmCreateContact.CreateContactMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockCreateContactParams{req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmCreateContact.t.Errorf("FreshdeskInterfaceMock.CreateContact got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateContact.t.Errorf("FreshdeskInterfaceMock.CreateContact got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateContact.CreateContactMock.defaultExpectation.results + if mm_results == nil { + mmCreateContact.t.Fatal("No results are set for the FreshdeskInterfaceMock.CreateContact") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmCreateContact.funcCreateContact != nil { + return mmCreateContact.funcCreateContact(req) + } + mmCreateContact.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.CreateContact. %v", req) + return +} + +// CreateContactAfterCounter returns a count of finished FreshdeskInterfaceMock.CreateContact invocations +func (mmCreateContact *FreshdeskInterfaceMock) CreateContactAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateContact.afterCreateContactCounter) +} + +// CreateContactBeforeCounter returns a count of FreshdeskInterfaceMock.CreateContact invocations +func (mmCreateContact *FreshdeskInterfaceMock) CreateContactBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateContact.beforeCreateContactCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.CreateContact. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateContact *mFreshdeskInterfaceMockCreateContact) Calls() []*FreshdeskInterfaceMockCreateContactParams { + mmCreateContact.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockCreateContactParams, len(mmCreateContact.callArgs)) + copy(argCopy, mmCreateContact.callArgs) + + mmCreateContact.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateContactDone returns true if the count of the CreateContact invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockCreateContactDone() bool { + if m.CreateContactMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateContactMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateContactMock.invocationsDone() +} + +// MinimockCreateContactInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockCreateContactInspect() { + for _, e := range m.CreateContactMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateContact with params: %#v", *e.params) + } + } + + afterCreateContactCounter := mm_atomic.LoadUint64(&m.afterCreateContactCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateContactMock.defaultExpectation != nil && afterCreateContactCounter < 1 { + if m.CreateContactMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateContact") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateContact with params: %#v", *m.CreateContactMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateContact != nil && afterCreateContactCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateContact") + } + + if !m.CreateContactMock.invocationsDone() && afterCreateContactCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.CreateContact but found %d calls", + mm_atomic.LoadUint64(&m.CreateContactMock.expectedInvocations), afterCreateContactCounter) + } +} + +type mFreshdeskInterfaceMockCreateTicket struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockCreateTicketExpectation + expectations []*FreshdeskInterfaceMockCreateTicketExpectation + + callArgs []*FreshdeskInterfaceMockCreateTicketParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockCreateTicketExpectation specifies expectation struct of the FreshdeskInterface.CreateTicket +type FreshdeskInterfaceMockCreateTicketExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockCreateTicketParams + paramPtrs *FreshdeskInterfaceMockCreateTicketParamPtrs + results *FreshdeskInterfaceMockCreateTicketResults + Counter uint64 +} + +// FreshdeskInterfaceMockCreateTicketParams contains parameters of the FreshdeskInterface.CreateTicket +type FreshdeskInterfaceMockCreateTicketParams struct { + req *TaskCreateTicketReq +} + +// FreshdeskInterfaceMockCreateTicketParamPtrs contains pointers to parameters of the FreshdeskInterface.CreateTicket +type FreshdeskInterfaceMockCreateTicketParamPtrs struct { + req **TaskCreateTicketReq +} + +// FreshdeskInterfaceMockCreateTicketResults contains results of the FreshdeskInterface.CreateTicket +type FreshdeskInterfaceMockCreateTicketResults struct { + tp1 *TaskCreateTicketResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Optional() *mFreshdeskInterfaceMockCreateTicket { + mmCreateTicket.optional = true + return mmCreateTicket +} + +// Expect sets up expected params for FreshdeskInterface.CreateTicket +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Expect(req *TaskCreateTicketReq) *mFreshdeskInterfaceMockCreateTicket { + if mmCreateTicket.mock.funcCreateTicket != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by Set") + } + + if mmCreateTicket.defaultExpectation == nil { + mmCreateTicket.defaultExpectation = &FreshdeskInterfaceMockCreateTicketExpectation{} + } + + if mmCreateTicket.defaultExpectation.paramPtrs != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by ExpectParams functions") + } + + mmCreateTicket.defaultExpectation.params = &FreshdeskInterfaceMockCreateTicketParams{req} + for _, e := range mmCreateTicket.expectations { + if minimock.Equal(e.params, mmCreateTicket.defaultExpectation.params) { + mmCreateTicket.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateTicket.defaultExpectation.params) + } + } + + return mmCreateTicket +} + +// ExpectReqParam1 sets up expected param req for FreshdeskInterface.CreateTicket +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) ExpectReqParam1(req *TaskCreateTicketReq) *mFreshdeskInterfaceMockCreateTicket { + if mmCreateTicket.mock.funcCreateTicket != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by Set") + } + + if mmCreateTicket.defaultExpectation == nil { + mmCreateTicket.defaultExpectation = &FreshdeskInterfaceMockCreateTicketExpectation{} + } + + if mmCreateTicket.defaultExpectation.params != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by Expect") + } + + if mmCreateTicket.defaultExpectation.paramPtrs == nil { + mmCreateTicket.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockCreateTicketParamPtrs{} + } + mmCreateTicket.defaultExpectation.paramPtrs.req = &req + + return mmCreateTicket +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.CreateTicket +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Inspect(f func(req *TaskCreateTicketReq)) *mFreshdeskInterfaceMockCreateTicket { + if mmCreateTicket.mock.inspectFuncCreateTicket != nil { + mmCreateTicket.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.CreateTicket") + } + + mmCreateTicket.mock.inspectFuncCreateTicket = f + + return mmCreateTicket +} + +// Return sets up results that will be returned by FreshdeskInterface.CreateTicket +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Return(tp1 *TaskCreateTicketResponse, err error) *FreshdeskInterfaceMock { + if mmCreateTicket.mock.funcCreateTicket != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by Set") + } + + if mmCreateTicket.defaultExpectation == nil { + mmCreateTicket.defaultExpectation = &FreshdeskInterfaceMockCreateTicketExpectation{mock: mmCreateTicket.mock} + } + mmCreateTicket.defaultExpectation.results = &FreshdeskInterfaceMockCreateTicketResults{tp1, err} + return mmCreateTicket.mock +} + +// Set uses given function f to mock the FreshdeskInterface.CreateTicket method +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Set(f func(req *TaskCreateTicketReq) (tp1 *TaskCreateTicketResponse, err error)) *FreshdeskInterfaceMock { + if mmCreateTicket.defaultExpectation != nil { + mmCreateTicket.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.CreateTicket method") + } + + if len(mmCreateTicket.expectations) > 0 { + mmCreateTicket.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.CreateTicket method") + } + + mmCreateTicket.mock.funcCreateTicket = f + return mmCreateTicket.mock +} + +// When sets expectation for the FreshdeskInterface.CreateTicket which will trigger the result defined by the following +// Then helper +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) When(req *TaskCreateTicketReq) *FreshdeskInterfaceMockCreateTicketExpectation { + if mmCreateTicket.mock.funcCreateTicket != nil { + mmCreateTicket.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicket mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockCreateTicketExpectation{ + mock: mmCreateTicket.mock, + params: &FreshdeskInterfaceMockCreateTicketParams{req}, + } + mmCreateTicket.expectations = append(mmCreateTicket.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.CreateTicket return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockCreateTicketExpectation) Then(tp1 *TaskCreateTicketResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockCreateTicketResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.CreateTicket should be invoked +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Times(n uint64) *mFreshdeskInterfaceMockCreateTicket { + if n == 0 { + mmCreateTicket.mock.t.Fatalf("Times of FreshdeskInterfaceMock.CreateTicket mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateTicket.expectedInvocations, n) + return mmCreateTicket +} + +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) invocationsDone() bool { + if len(mmCreateTicket.expectations) == 0 && mmCreateTicket.defaultExpectation == nil && mmCreateTicket.mock.funcCreateTicket == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateTicket.mock.afterCreateTicketCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateTicket.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateTicket implements FreshdeskInterface +func (mmCreateTicket *FreshdeskInterfaceMock) CreateTicket(req *TaskCreateTicketReq) (tp1 *TaskCreateTicketResponse, err error) { + mm_atomic.AddUint64(&mmCreateTicket.beforeCreateTicketCounter, 1) + defer mm_atomic.AddUint64(&mmCreateTicket.afterCreateTicketCounter, 1) + + if mmCreateTicket.inspectFuncCreateTicket != nil { + mmCreateTicket.inspectFuncCreateTicket(req) + } + + mm_params := FreshdeskInterfaceMockCreateTicketParams{req} + + // Record call args + mmCreateTicket.CreateTicketMock.mutex.Lock() + mmCreateTicket.CreateTicketMock.callArgs = append(mmCreateTicket.CreateTicketMock.callArgs, &mm_params) + mmCreateTicket.CreateTicketMock.mutex.Unlock() + + for _, e := range mmCreateTicket.CreateTicketMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmCreateTicket.CreateTicketMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateTicket.CreateTicketMock.defaultExpectation.Counter, 1) + mm_want := mmCreateTicket.CreateTicketMock.defaultExpectation.params + mm_want_ptrs := mmCreateTicket.CreateTicketMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockCreateTicketParams{req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmCreateTicket.t.Errorf("FreshdeskInterfaceMock.CreateTicket got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateTicket.t.Errorf("FreshdeskInterfaceMock.CreateTicket got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateTicket.CreateTicketMock.defaultExpectation.results + if mm_results == nil { + mmCreateTicket.t.Fatal("No results are set for the FreshdeskInterfaceMock.CreateTicket") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmCreateTicket.funcCreateTicket != nil { + return mmCreateTicket.funcCreateTicket(req) + } + mmCreateTicket.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.CreateTicket. %v", req) + return +} + +// CreateTicketAfterCounter returns a count of finished FreshdeskInterfaceMock.CreateTicket invocations +func (mmCreateTicket *FreshdeskInterfaceMock) CreateTicketAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTicket.afterCreateTicketCounter) +} + +// CreateTicketBeforeCounter returns a count of FreshdeskInterfaceMock.CreateTicket invocations +func (mmCreateTicket *FreshdeskInterfaceMock) CreateTicketBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTicket.beforeCreateTicketCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.CreateTicket. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateTicket *mFreshdeskInterfaceMockCreateTicket) Calls() []*FreshdeskInterfaceMockCreateTicketParams { + mmCreateTicket.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockCreateTicketParams, len(mmCreateTicket.callArgs)) + copy(argCopy, mmCreateTicket.callArgs) + + mmCreateTicket.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateTicketDone returns true if the count of the CreateTicket invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockCreateTicketDone() bool { + if m.CreateTicketMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateTicketMock.invocationsDone() +} + +// MinimockCreateTicketInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockCreateTicketInspect() { + for _, e := range m.CreateTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateTicket with params: %#v", *e.params) + } + } + + afterCreateTicketCounter := mm_atomic.LoadUint64(&m.afterCreateTicketCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateTicketMock.defaultExpectation != nil && afterCreateTicketCounter < 1 { + if m.CreateTicketMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateTicket") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateTicket with params: %#v", *m.CreateTicketMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateTicket != nil && afterCreateTicketCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateTicket") + } + + if !m.CreateTicketMock.invocationsDone() && afterCreateTicketCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.CreateTicket but found %d calls", + mm_atomic.LoadUint64(&m.CreateTicketMock.expectedInvocations), afterCreateTicketCounter) + } +} + +type mFreshdeskInterfaceMockCreateTicketNote struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockCreateTicketNoteExpectation + expectations []*FreshdeskInterfaceMockCreateTicketNoteExpectation + + callArgs []*FreshdeskInterfaceMockCreateTicketNoteParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockCreateTicketNoteExpectation specifies expectation struct of the FreshdeskInterface.CreateTicketNote +type FreshdeskInterfaceMockCreateTicketNoteExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockCreateTicketNoteParams + paramPtrs *FreshdeskInterfaceMockCreateTicketNoteParamPtrs + results *FreshdeskInterfaceMockCreateTicketNoteResults + Counter uint64 +} + +// FreshdeskInterfaceMockCreateTicketNoteParams contains parameters of the FreshdeskInterface.CreateTicketNote +type FreshdeskInterfaceMockCreateTicketNoteParams struct { + ticketID int64 + req *TaskCreateTicketNoteReq +} + +// FreshdeskInterfaceMockCreateTicketNoteParamPtrs contains pointers to parameters of the FreshdeskInterface.CreateTicketNote +type FreshdeskInterfaceMockCreateTicketNoteParamPtrs struct { + ticketID *int64 + req **TaskCreateTicketNoteReq +} + +// FreshdeskInterfaceMockCreateTicketNoteResults contains results of the FreshdeskInterface.CreateTicketNote +type FreshdeskInterfaceMockCreateTicketNoteResults struct { + tp1 *TaskCreateTicketNoteResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Optional() *mFreshdeskInterfaceMockCreateTicketNote { + mmCreateTicketNote.optional = true + return mmCreateTicketNote +} + +// Expect sets up expected params for FreshdeskInterface.CreateTicketNote +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Expect(ticketID int64, req *TaskCreateTicketNoteReq) *mFreshdeskInterfaceMockCreateTicketNote { + if mmCreateTicketNote.mock.funcCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Set") + } + + if mmCreateTicketNote.defaultExpectation == nil { + mmCreateTicketNote.defaultExpectation = &FreshdeskInterfaceMockCreateTicketNoteExpectation{} + } + + if mmCreateTicketNote.defaultExpectation.paramPtrs != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by ExpectParams functions") + } + + mmCreateTicketNote.defaultExpectation.params = &FreshdeskInterfaceMockCreateTicketNoteParams{ticketID, req} + for _, e := range mmCreateTicketNote.expectations { + if minimock.Equal(e.params, mmCreateTicketNote.defaultExpectation.params) { + mmCreateTicketNote.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmCreateTicketNote.defaultExpectation.params) + } + } + + return mmCreateTicketNote +} + +// ExpectTicketIDParam1 sets up expected param ticketID for FreshdeskInterface.CreateTicketNote +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) ExpectTicketIDParam1(ticketID int64) *mFreshdeskInterfaceMockCreateTicketNote { + if mmCreateTicketNote.mock.funcCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Set") + } + + if mmCreateTicketNote.defaultExpectation == nil { + mmCreateTicketNote.defaultExpectation = &FreshdeskInterfaceMockCreateTicketNoteExpectation{} + } + + if mmCreateTicketNote.defaultExpectation.params != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Expect") + } + + if mmCreateTicketNote.defaultExpectation.paramPtrs == nil { + mmCreateTicketNote.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockCreateTicketNoteParamPtrs{} + } + mmCreateTicketNote.defaultExpectation.paramPtrs.ticketID = &ticketID + + return mmCreateTicketNote +} + +// ExpectReqParam2 sets up expected param req for FreshdeskInterface.CreateTicketNote +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) ExpectReqParam2(req *TaskCreateTicketNoteReq) *mFreshdeskInterfaceMockCreateTicketNote { + if mmCreateTicketNote.mock.funcCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Set") + } + + if mmCreateTicketNote.defaultExpectation == nil { + mmCreateTicketNote.defaultExpectation = &FreshdeskInterfaceMockCreateTicketNoteExpectation{} + } + + if mmCreateTicketNote.defaultExpectation.params != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Expect") + } + + if mmCreateTicketNote.defaultExpectation.paramPtrs == nil { + mmCreateTicketNote.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockCreateTicketNoteParamPtrs{} + } + mmCreateTicketNote.defaultExpectation.paramPtrs.req = &req + + return mmCreateTicketNote +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.CreateTicketNote +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Inspect(f func(ticketID int64, req *TaskCreateTicketNoteReq)) *mFreshdeskInterfaceMockCreateTicketNote { + if mmCreateTicketNote.mock.inspectFuncCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.CreateTicketNote") + } + + mmCreateTicketNote.mock.inspectFuncCreateTicketNote = f + + return mmCreateTicketNote +} + +// Return sets up results that will be returned by FreshdeskInterface.CreateTicketNote +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Return(tp1 *TaskCreateTicketNoteResponse, err error) *FreshdeskInterfaceMock { + if mmCreateTicketNote.mock.funcCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Set") + } + + if mmCreateTicketNote.defaultExpectation == nil { + mmCreateTicketNote.defaultExpectation = &FreshdeskInterfaceMockCreateTicketNoteExpectation{mock: mmCreateTicketNote.mock} + } + mmCreateTicketNote.defaultExpectation.results = &FreshdeskInterfaceMockCreateTicketNoteResults{tp1, err} + return mmCreateTicketNote.mock +} + +// Set uses given function f to mock the FreshdeskInterface.CreateTicketNote method +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Set(f func(ticketID int64, req *TaskCreateTicketNoteReq) (tp1 *TaskCreateTicketNoteResponse, err error)) *FreshdeskInterfaceMock { + if mmCreateTicketNote.defaultExpectation != nil { + mmCreateTicketNote.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.CreateTicketNote method") + } + + if len(mmCreateTicketNote.expectations) > 0 { + mmCreateTicketNote.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.CreateTicketNote method") + } + + mmCreateTicketNote.mock.funcCreateTicketNote = f + return mmCreateTicketNote.mock +} + +// When sets expectation for the FreshdeskInterface.CreateTicketNote which will trigger the result defined by the following +// Then helper +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) When(ticketID int64, req *TaskCreateTicketNoteReq) *FreshdeskInterfaceMockCreateTicketNoteExpectation { + if mmCreateTicketNote.mock.funcCreateTicketNote != nil { + mmCreateTicketNote.mock.t.Fatalf("FreshdeskInterfaceMock.CreateTicketNote mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockCreateTicketNoteExpectation{ + mock: mmCreateTicketNote.mock, + params: &FreshdeskInterfaceMockCreateTicketNoteParams{ticketID, req}, + } + mmCreateTicketNote.expectations = append(mmCreateTicketNote.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.CreateTicketNote return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockCreateTicketNoteExpectation) Then(tp1 *TaskCreateTicketNoteResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockCreateTicketNoteResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.CreateTicketNote should be invoked +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Times(n uint64) *mFreshdeskInterfaceMockCreateTicketNote { + if n == 0 { + mmCreateTicketNote.mock.t.Fatalf("Times of FreshdeskInterfaceMock.CreateTicketNote mock can not be zero") + } + mm_atomic.StoreUint64(&mmCreateTicketNote.expectedInvocations, n) + return mmCreateTicketNote +} + +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) invocationsDone() bool { + if len(mmCreateTicketNote.expectations) == 0 && mmCreateTicketNote.defaultExpectation == nil && mmCreateTicketNote.mock.funcCreateTicketNote == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmCreateTicketNote.mock.afterCreateTicketNoteCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmCreateTicketNote.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// CreateTicketNote implements FreshdeskInterface +func (mmCreateTicketNote *FreshdeskInterfaceMock) CreateTicketNote(ticketID int64, req *TaskCreateTicketNoteReq) (tp1 *TaskCreateTicketNoteResponse, err error) { + mm_atomic.AddUint64(&mmCreateTicketNote.beforeCreateTicketNoteCounter, 1) + defer mm_atomic.AddUint64(&mmCreateTicketNote.afterCreateTicketNoteCounter, 1) + + if mmCreateTicketNote.inspectFuncCreateTicketNote != nil { + mmCreateTicketNote.inspectFuncCreateTicketNote(ticketID, req) + } + + mm_params := FreshdeskInterfaceMockCreateTicketNoteParams{ticketID, req} + + // Record call args + mmCreateTicketNote.CreateTicketNoteMock.mutex.Lock() + mmCreateTicketNote.CreateTicketNoteMock.callArgs = append(mmCreateTicketNote.CreateTicketNoteMock.callArgs, &mm_params) + mmCreateTicketNote.CreateTicketNoteMock.mutex.Unlock() + + for _, e := range mmCreateTicketNote.CreateTicketNoteMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmCreateTicketNote.CreateTicketNoteMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmCreateTicketNote.CreateTicketNoteMock.defaultExpectation.Counter, 1) + mm_want := mmCreateTicketNote.CreateTicketNoteMock.defaultExpectation.params + mm_want_ptrs := mmCreateTicketNote.CreateTicketNoteMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockCreateTicketNoteParams{ticketID, req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ticketID != nil && !minimock.Equal(*mm_want_ptrs.ticketID, mm_got.ticketID) { + mmCreateTicketNote.t.Errorf("FreshdeskInterfaceMock.CreateTicketNote got unexpected parameter ticketID, want: %#v, got: %#v%s\n", *mm_want_ptrs.ticketID, mm_got.ticketID, minimock.Diff(*mm_want_ptrs.ticketID, mm_got.ticketID)) + } + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmCreateTicketNote.t.Errorf("FreshdeskInterfaceMock.CreateTicketNote got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmCreateTicketNote.t.Errorf("FreshdeskInterfaceMock.CreateTicketNote got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmCreateTicketNote.CreateTicketNoteMock.defaultExpectation.results + if mm_results == nil { + mmCreateTicketNote.t.Fatal("No results are set for the FreshdeskInterfaceMock.CreateTicketNote") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmCreateTicketNote.funcCreateTicketNote != nil { + return mmCreateTicketNote.funcCreateTicketNote(ticketID, req) + } + mmCreateTicketNote.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.CreateTicketNote. %v %v", ticketID, req) + return +} + +// CreateTicketNoteAfterCounter returns a count of finished FreshdeskInterfaceMock.CreateTicketNote invocations +func (mmCreateTicketNote *FreshdeskInterfaceMock) CreateTicketNoteAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTicketNote.afterCreateTicketNoteCounter) +} + +// CreateTicketNoteBeforeCounter returns a count of FreshdeskInterfaceMock.CreateTicketNote invocations +func (mmCreateTicketNote *FreshdeskInterfaceMock) CreateTicketNoteBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmCreateTicketNote.beforeCreateTicketNoteCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.CreateTicketNote. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmCreateTicketNote *mFreshdeskInterfaceMockCreateTicketNote) Calls() []*FreshdeskInterfaceMockCreateTicketNoteParams { + mmCreateTicketNote.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockCreateTicketNoteParams, len(mmCreateTicketNote.callArgs)) + copy(argCopy, mmCreateTicketNote.callArgs) + + mmCreateTicketNote.mutex.RUnlock() + + return argCopy +} + +// MinimockCreateTicketNoteDone returns true if the count of the CreateTicketNote invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockCreateTicketNoteDone() bool { + if m.CreateTicketNoteMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.CreateTicketNoteMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.CreateTicketNoteMock.invocationsDone() +} + +// MinimockCreateTicketNoteInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockCreateTicketNoteInspect() { + for _, e := range m.CreateTicketNoteMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateTicketNote with params: %#v", *e.params) + } + } + + afterCreateTicketNoteCounter := mm_atomic.LoadUint64(&m.afterCreateTicketNoteCounter) + // if default expectation was set then invocations count should be greater than zero + if m.CreateTicketNoteMock.defaultExpectation != nil && afterCreateTicketNoteCounter < 1 { + if m.CreateTicketNoteMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateTicketNote") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.CreateTicketNote with params: %#v", *m.CreateTicketNoteMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcCreateTicketNote != nil && afterCreateTicketNoteCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.CreateTicketNote") + } + + if !m.CreateTicketNoteMock.invocationsDone() && afterCreateTicketNoteCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.CreateTicketNote but found %d calls", + mm_atomic.LoadUint64(&m.CreateTicketNoteMock.expectedInvocations), afterCreateTicketNoteCounter) + } +} + +type mFreshdeskInterfaceMockGetAgent struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetAgentExpectation + expectations []*FreshdeskInterfaceMockGetAgentExpectation + + callArgs []*FreshdeskInterfaceMockGetAgentParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetAgentExpectation specifies expectation struct of the FreshdeskInterface.GetAgent +type FreshdeskInterfaceMockGetAgentExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetAgentParams + paramPtrs *FreshdeskInterfaceMockGetAgentParamPtrs + results *FreshdeskInterfaceMockGetAgentResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetAgentParams contains parameters of the FreshdeskInterface.GetAgent +type FreshdeskInterfaceMockGetAgentParams struct { + agentID int64 +} + +// FreshdeskInterfaceMockGetAgentParamPtrs contains pointers to parameters of the FreshdeskInterface.GetAgent +type FreshdeskInterfaceMockGetAgentParamPtrs struct { + agentID *int64 +} + +// FreshdeskInterfaceMockGetAgentResults contains results of the FreshdeskInterface.GetAgent +type FreshdeskInterfaceMockGetAgentResults struct { + tp1 *TaskGetAgentResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Optional() *mFreshdeskInterfaceMockGetAgent { + mmGetAgent.optional = true + return mmGetAgent +} + +// Expect sets up expected params for FreshdeskInterface.GetAgent +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Expect(agentID int64) *mFreshdeskInterfaceMockGetAgent { + if mmGetAgent.mock.funcGetAgent != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by Set") + } + + if mmGetAgent.defaultExpectation == nil { + mmGetAgent.defaultExpectation = &FreshdeskInterfaceMockGetAgentExpectation{} + } + + if mmGetAgent.defaultExpectation.paramPtrs != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by ExpectParams functions") + } + + mmGetAgent.defaultExpectation.params = &FreshdeskInterfaceMockGetAgentParams{agentID} + for _, e := range mmGetAgent.expectations { + if minimock.Equal(e.params, mmGetAgent.defaultExpectation.params) { + mmGetAgent.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAgent.defaultExpectation.params) + } + } + + return mmGetAgent +} + +// ExpectAgentIDParam1 sets up expected param agentID for FreshdeskInterface.GetAgent +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) ExpectAgentIDParam1(agentID int64) *mFreshdeskInterfaceMockGetAgent { + if mmGetAgent.mock.funcGetAgent != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by Set") + } + + if mmGetAgent.defaultExpectation == nil { + mmGetAgent.defaultExpectation = &FreshdeskInterfaceMockGetAgentExpectation{} + } + + if mmGetAgent.defaultExpectation.params != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by Expect") + } + + if mmGetAgent.defaultExpectation.paramPtrs == nil { + mmGetAgent.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAgentParamPtrs{} + } + mmGetAgent.defaultExpectation.paramPtrs.agentID = &agentID + + return mmGetAgent +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetAgent +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Inspect(f func(agentID int64)) *mFreshdeskInterfaceMockGetAgent { + if mmGetAgent.mock.inspectFuncGetAgent != nil { + mmGetAgent.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetAgent") + } + + mmGetAgent.mock.inspectFuncGetAgent = f + + return mmGetAgent +} + +// Return sets up results that will be returned by FreshdeskInterface.GetAgent +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Return(tp1 *TaskGetAgentResponse, err error) *FreshdeskInterfaceMock { + if mmGetAgent.mock.funcGetAgent != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by Set") + } + + if mmGetAgent.defaultExpectation == nil { + mmGetAgent.defaultExpectation = &FreshdeskInterfaceMockGetAgentExpectation{mock: mmGetAgent.mock} + } + mmGetAgent.defaultExpectation.results = &FreshdeskInterfaceMockGetAgentResults{tp1, err} + return mmGetAgent.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetAgent method +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Set(f func(agentID int64) (tp1 *TaskGetAgentResponse, err error)) *FreshdeskInterfaceMock { + if mmGetAgent.defaultExpectation != nil { + mmGetAgent.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetAgent method") + } + + if len(mmGetAgent.expectations) > 0 { + mmGetAgent.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetAgent method") + } + + mmGetAgent.mock.funcGetAgent = f + return mmGetAgent.mock +} + +// When sets expectation for the FreshdeskInterface.GetAgent which will trigger the result defined by the following +// Then helper +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) When(agentID int64) *FreshdeskInterfaceMockGetAgentExpectation { + if mmGetAgent.mock.funcGetAgent != nil { + mmGetAgent.mock.t.Fatalf("FreshdeskInterfaceMock.GetAgent mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetAgentExpectation{ + mock: mmGetAgent.mock, + params: &FreshdeskInterfaceMockGetAgentParams{agentID}, + } + mmGetAgent.expectations = append(mmGetAgent.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetAgent return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetAgentExpectation) Then(tp1 *TaskGetAgentResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetAgentResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetAgent should be invoked +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Times(n uint64) *mFreshdeskInterfaceMockGetAgent { + if n == 0 { + mmGetAgent.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetAgent mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetAgent.expectedInvocations, n) + return mmGetAgent +} + +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) invocationsDone() bool { + if len(mmGetAgent.expectations) == 0 && mmGetAgent.defaultExpectation == nil && mmGetAgent.mock.funcGetAgent == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetAgent.mock.afterGetAgentCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetAgent.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetAgent implements FreshdeskInterface +func (mmGetAgent *FreshdeskInterfaceMock) GetAgent(agentID int64) (tp1 *TaskGetAgentResponse, err error) { + mm_atomic.AddUint64(&mmGetAgent.beforeGetAgentCounter, 1) + defer mm_atomic.AddUint64(&mmGetAgent.afterGetAgentCounter, 1) + + if mmGetAgent.inspectFuncGetAgent != nil { + mmGetAgent.inspectFuncGetAgent(agentID) + } + + mm_params := FreshdeskInterfaceMockGetAgentParams{agentID} + + // Record call args + mmGetAgent.GetAgentMock.mutex.Lock() + mmGetAgent.GetAgentMock.callArgs = append(mmGetAgent.GetAgentMock.callArgs, &mm_params) + mmGetAgent.GetAgentMock.mutex.Unlock() + + for _, e := range mmGetAgent.GetAgentMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetAgent.GetAgentMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetAgent.GetAgentMock.defaultExpectation.Counter, 1) + mm_want := mmGetAgent.GetAgentMock.defaultExpectation.params + mm_want_ptrs := mmGetAgent.GetAgentMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetAgentParams{agentID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.agentID != nil && !minimock.Equal(*mm_want_ptrs.agentID, mm_got.agentID) { + mmGetAgent.t.Errorf("FreshdeskInterfaceMock.GetAgent got unexpected parameter agentID, want: %#v, got: %#v%s\n", *mm_want_ptrs.agentID, mm_got.agentID, minimock.Diff(*mm_want_ptrs.agentID, mm_got.agentID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetAgent.t.Errorf("FreshdeskInterfaceMock.GetAgent got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetAgent.GetAgentMock.defaultExpectation.results + if mm_results == nil { + mmGetAgent.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetAgent") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetAgent.funcGetAgent != nil { + return mmGetAgent.funcGetAgent(agentID) + } + mmGetAgent.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetAgent. %v", agentID) + return +} + +// GetAgentAfterCounter returns a count of finished FreshdeskInterfaceMock.GetAgent invocations +func (mmGetAgent *FreshdeskInterfaceMock) GetAgentAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAgent.afterGetAgentCounter) +} + +// GetAgentBeforeCounter returns a count of FreshdeskInterfaceMock.GetAgent invocations +func (mmGetAgent *FreshdeskInterfaceMock) GetAgentBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAgent.beforeGetAgentCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetAgent. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetAgent *mFreshdeskInterfaceMockGetAgent) Calls() []*FreshdeskInterfaceMockGetAgentParams { + mmGetAgent.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetAgentParams, len(mmGetAgent.callArgs)) + copy(argCopy, mmGetAgent.callArgs) + + mmGetAgent.mutex.RUnlock() + + return argCopy +} + +// MinimockGetAgentDone returns true if the count of the GetAgent invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetAgentDone() bool { + if m.GetAgentMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetAgentMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetAgentMock.invocationsDone() +} + +// MinimockGetAgentInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetAgentInspect() { + for _, e := range m.GetAgentMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAgent with params: %#v", *e.params) + } + } + + afterGetAgentCounter := mm_atomic.LoadUint64(&m.afterGetAgentCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetAgentMock.defaultExpectation != nil && afterGetAgentCounter < 1 { + if m.GetAgentMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAgent") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAgent with params: %#v", *m.GetAgentMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetAgent != nil && afterGetAgentCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAgent") + } + + if !m.GetAgentMock.invocationsDone() && afterGetAgentCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetAgent but found %d calls", + mm_atomic.LoadUint64(&m.GetAgentMock.expectedInvocations), afterGetAgentCounter) + } +} + +type mFreshdeskInterfaceMockGetAll struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetAllExpectation + expectations []*FreshdeskInterfaceMockGetAllExpectation + + callArgs []*FreshdeskInterfaceMockGetAllParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetAllExpectation specifies expectation struct of the FreshdeskInterface.GetAll +type FreshdeskInterfaceMockGetAllExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetAllParams + paramPtrs *FreshdeskInterfaceMockGetAllParamPtrs + results *FreshdeskInterfaceMockGetAllResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetAllParams contains parameters of the FreshdeskInterface.GetAll +type FreshdeskInterfaceMockGetAllParams struct { + objectType string + pagination bool + paginationPath string +} + +// FreshdeskInterfaceMockGetAllParamPtrs contains pointers to parameters of the FreshdeskInterface.GetAll +type FreshdeskInterfaceMockGetAllParamPtrs struct { + objectType *string + pagination *bool + paginationPath *string +} + +// FreshdeskInterfaceMockGetAllResults contains results of the FreshdeskInterface.GetAll +type FreshdeskInterfaceMockGetAllResults struct { + ta1 []TaskGetAllResponse + s1 string + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Optional() *mFreshdeskInterfaceMockGetAll { + mmGetAll.optional = true + return mmGetAll +} + +// Expect sets up expected params for FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Expect(objectType string, pagination bool, paginationPath string) *mFreshdeskInterfaceMockGetAll { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + if mmGetAll.defaultExpectation == nil { + mmGetAll.defaultExpectation = &FreshdeskInterfaceMockGetAllExpectation{} + } + + if mmGetAll.defaultExpectation.paramPtrs != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by ExpectParams functions") + } + + mmGetAll.defaultExpectation.params = &FreshdeskInterfaceMockGetAllParams{objectType, pagination, paginationPath} + for _, e := range mmGetAll.expectations { + if minimock.Equal(e.params, mmGetAll.defaultExpectation.params) { + mmGetAll.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAll.defaultExpectation.params) + } + } + + return mmGetAll +} + +// ExpectObjectTypeParam1 sets up expected param objectType for FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) ExpectObjectTypeParam1(objectType string) *mFreshdeskInterfaceMockGetAll { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + if mmGetAll.defaultExpectation == nil { + mmGetAll.defaultExpectation = &FreshdeskInterfaceMockGetAllExpectation{} + } + + if mmGetAll.defaultExpectation.params != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Expect") + } + + if mmGetAll.defaultExpectation.paramPtrs == nil { + mmGetAll.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllParamPtrs{} + } + mmGetAll.defaultExpectation.paramPtrs.objectType = &objectType + + return mmGetAll +} + +// ExpectPaginationParam2 sets up expected param pagination for FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) ExpectPaginationParam2(pagination bool) *mFreshdeskInterfaceMockGetAll { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + if mmGetAll.defaultExpectation == nil { + mmGetAll.defaultExpectation = &FreshdeskInterfaceMockGetAllExpectation{} + } + + if mmGetAll.defaultExpectation.params != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Expect") + } + + if mmGetAll.defaultExpectation.paramPtrs == nil { + mmGetAll.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllParamPtrs{} + } + mmGetAll.defaultExpectation.paramPtrs.pagination = &pagination + + return mmGetAll +} + +// ExpectPaginationPathParam3 sets up expected param paginationPath for FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) ExpectPaginationPathParam3(paginationPath string) *mFreshdeskInterfaceMockGetAll { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + if mmGetAll.defaultExpectation == nil { + mmGetAll.defaultExpectation = &FreshdeskInterfaceMockGetAllExpectation{} + } + + if mmGetAll.defaultExpectation.params != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Expect") + } + + if mmGetAll.defaultExpectation.paramPtrs == nil { + mmGetAll.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllParamPtrs{} + } + mmGetAll.defaultExpectation.paramPtrs.paginationPath = &paginationPath + + return mmGetAll +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Inspect(f func(objectType string, pagination bool, paginationPath string)) *mFreshdeskInterfaceMockGetAll { + if mmGetAll.mock.inspectFuncGetAll != nil { + mmGetAll.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetAll") + } + + mmGetAll.mock.inspectFuncGetAll = f + + return mmGetAll +} + +// Return sets up results that will be returned by FreshdeskInterface.GetAll +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Return(ta1 []TaskGetAllResponse, s1 string, err error) *FreshdeskInterfaceMock { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + if mmGetAll.defaultExpectation == nil { + mmGetAll.defaultExpectation = &FreshdeskInterfaceMockGetAllExpectation{mock: mmGetAll.mock} + } + mmGetAll.defaultExpectation.results = &FreshdeskInterfaceMockGetAllResults{ta1, s1, err} + return mmGetAll.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetAll method +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Set(f func(objectType string, pagination bool, paginationPath string) (ta1 []TaskGetAllResponse, s1 string, err error)) *FreshdeskInterfaceMock { + if mmGetAll.defaultExpectation != nil { + mmGetAll.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetAll method") + } + + if len(mmGetAll.expectations) > 0 { + mmGetAll.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetAll method") + } + + mmGetAll.mock.funcGetAll = f + return mmGetAll.mock +} + +// When sets expectation for the FreshdeskInterface.GetAll which will trigger the result defined by the following +// Then helper +func (mmGetAll *mFreshdeskInterfaceMockGetAll) When(objectType string, pagination bool, paginationPath string) *FreshdeskInterfaceMockGetAllExpectation { + if mmGetAll.mock.funcGetAll != nil { + mmGetAll.mock.t.Fatalf("FreshdeskInterfaceMock.GetAll mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetAllExpectation{ + mock: mmGetAll.mock, + params: &FreshdeskInterfaceMockGetAllParams{objectType, pagination, paginationPath}, + } + mmGetAll.expectations = append(mmGetAll.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetAll return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetAllExpectation) Then(ta1 []TaskGetAllResponse, s1 string, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetAllResults{ta1, s1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetAll should be invoked +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Times(n uint64) *mFreshdeskInterfaceMockGetAll { + if n == 0 { + mmGetAll.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetAll mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetAll.expectedInvocations, n) + return mmGetAll +} + +func (mmGetAll *mFreshdeskInterfaceMockGetAll) invocationsDone() bool { + if len(mmGetAll.expectations) == 0 && mmGetAll.defaultExpectation == nil && mmGetAll.mock.funcGetAll == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetAll.mock.afterGetAllCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetAll.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetAll implements FreshdeskInterface +func (mmGetAll *FreshdeskInterfaceMock) GetAll(objectType string, pagination bool, paginationPath string) (ta1 []TaskGetAllResponse, s1 string, err error) { + mm_atomic.AddUint64(&mmGetAll.beforeGetAllCounter, 1) + defer mm_atomic.AddUint64(&mmGetAll.afterGetAllCounter, 1) + + if mmGetAll.inspectFuncGetAll != nil { + mmGetAll.inspectFuncGetAll(objectType, pagination, paginationPath) + } + + mm_params := FreshdeskInterfaceMockGetAllParams{objectType, pagination, paginationPath} + + // Record call args + mmGetAll.GetAllMock.mutex.Lock() + mmGetAll.GetAllMock.callArgs = append(mmGetAll.GetAllMock.callArgs, &mm_params) + mmGetAll.GetAllMock.mutex.Unlock() + + for _, e := range mmGetAll.GetAllMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ta1, e.results.s1, e.results.err + } + } + + if mmGetAll.GetAllMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetAll.GetAllMock.defaultExpectation.Counter, 1) + mm_want := mmGetAll.GetAllMock.defaultExpectation.params + mm_want_ptrs := mmGetAll.GetAllMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetAllParams{objectType, pagination, paginationPath} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.objectType != nil && !minimock.Equal(*mm_want_ptrs.objectType, mm_got.objectType) { + mmGetAll.t.Errorf("FreshdeskInterfaceMock.GetAll got unexpected parameter objectType, want: %#v, got: %#v%s\n", *mm_want_ptrs.objectType, mm_got.objectType, minimock.Diff(*mm_want_ptrs.objectType, mm_got.objectType)) + } + + if mm_want_ptrs.pagination != nil && !minimock.Equal(*mm_want_ptrs.pagination, mm_got.pagination) { + mmGetAll.t.Errorf("FreshdeskInterfaceMock.GetAll got unexpected parameter pagination, want: %#v, got: %#v%s\n", *mm_want_ptrs.pagination, mm_got.pagination, minimock.Diff(*mm_want_ptrs.pagination, mm_got.pagination)) + } + + if mm_want_ptrs.paginationPath != nil && !minimock.Equal(*mm_want_ptrs.paginationPath, mm_got.paginationPath) { + mmGetAll.t.Errorf("FreshdeskInterfaceMock.GetAll got unexpected parameter paginationPath, want: %#v, got: %#v%s\n", *mm_want_ptrs.paginationPath, mm_got.paginationPath, minimock.Diff(*mm_want_ptrs.paginationPath, mm_got.paginationPath)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetAll.t.Errorf("FreshdeskInterfaceMock.GetAll got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetAll.GetAllMock.defaultExpectation.results + if mm_results == nil { + mmGetAll.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetAll") + } + return (*mm_results).ta1, (*mm_results).s1, (*mm_results).err + } + if mmGetAll.funcGetAll != nil { + return mmGetAll.funcGetAll(objectType, pagination, paginationPath) + } + mmGetAll.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetAll. %v %v %v", objectType, pagination, paginationPath) + return +} + +// GetAllAfterCounter returns a count of finished FreshdeskInterfaceMock.GetAll invocations +func (mmGetAll *FreshdeskInterfaceMock) GetAllAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAll.afterGetAllCounter) +} + +// GetAllBeforeCounter returns a count of FreshdeskInterfaceMock.GetAll invocations +func (mmGetAll *FreshdeskInterfaceMock) GetAllBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAll.beforeGetAllCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetAll. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetAll *mFreshdeskInterfaceMockGetAll) Calls() []*FreshdeskInterfaceMockGetAllParams { + mmGetAll.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetAllParams, len(mmGetAll.callArgs)) + copy(argCopy, mmGetAll.callArgs) + + mmGetAll.mutex.RUnlock() + + return argCopy +} + +// MinimockGetAllDone returns true if the count of the GetAll invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetAllDone() bool { + if m.GetAllMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetAllMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetAllMock.invocationsDone() +} + +// MinimockGetAllInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetAllInspect() { + for _, e := range m.GetAllMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAll with params: %#v", *e.params) + } + } + + afterGetAllCounter := mm_atomic.LoadUint64(&m.afterGetAllCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetAllMock.defaultExpectation != nil && afterGetAllCounter < 1 { + if m.GetAllMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAll") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAll with params: %#v", *m.GetAllMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetAll != nil && afterGetAllCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAll") + } + + if !m.GetAllMock.invocationsDone() && afterGetAllCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetAll but found %d calls", + mm_atomic.LoadUint64(&m.GetAllMock.expectedInvocations), afterGetAllCounter) + } +} + +type mFreshdeskInterfaceMockGetAllConversations struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetAllConversationsExpectation + expectations []*FreshdeskInterfaceMockGetAllConversationsExpectation + + callArgs []*FreshdeskInterfaceMockGetAllConversationsParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetAllConversationsExpectation specifies expectation struct of the FreshdeskInterface.GetAllConversations +type FreshdeskInterfaceMockGetAllConversationsExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetAllConversationsParams + paramPtrs *FreshdeskInterfaceMockGetAllConversationsParamPtrs + results *FreshdeskInterfaceMockGetAllConversationsResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetAllConversationsParams contains parameters of the FreshdeskInterface.GetAllConversations +type FreshdeskInterfaceMockGetAllConversationsParams struct { + ticketID int64 + pagination bool + paginationPath string +} + +// FreshdeskInterfaceMockGetAllConversationsParamPtrs contains pointers to parameters of the FreshdeskInterface.GetAllConversations +type FreshdeskInterfaceMockGetAllConversationsParamPtrs struct { + ticketID *int64 + pagination *bool + paginationPath *string +} + +// FreshdeskInterfaceMockGetAllConversationsResults contains results of the FreshdeskInterface.GetAllConversations +type FreshdeskInterfaceMockGetAllConversationsResults struct { + ta1 []TaskGetAllConversationsResponse + s1 string + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Optional() *mFreshdeskInterfaceMockGetAllConversations { + mmGetAllConversations.optional = true + return mmGetAllConversations +} + +// Expect sets up expected params for FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Expect(ticketID int64, pagination bool, paginationPath string) *mFreshdeskInterfaceMockGetAllConversations { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + if mmGetAllConversations.defaultExpectation == nil { + mmGetAllConversations.defaultExpectation = &FreshdeskInterfaceMockGetAllConversationsExpectation{} + } + + if mmGetAllConversations.defaultExpectation.paramPtrs != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by ExpectParams functions") + } + + mmGetAllConversations.defaultExpectation.params = &FreshdeskInterfaceMockGetAllConversationsParams{ticketID, pagination, paginationPath} + for _, e := range mmGetAllConversations.expectations { + if minimock.Equal(e.params, mmGetAllConversations.defaultExpectation.params) { + mmGetAllConversations.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllConversations.defaultExpectation.params) + } + } + + return mmGetAllConversations +} + +// ExpectTicketIDParam1 sets up expected param ticketID for FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) ExpectTicketIDParam1(ticketID int64) *mFreshdeskInterfaceMockGetAllConversations { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + if mmGetAllConversations.defaultExpectation == nil { + mmGetAllConversations.defaultExpectation = &FreshdeskInterfaceMockGetAllConversationsExpectation{} + } + + if mmGetAllConversations.defaultExpectation.params != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Expect") + } + + if mmGetAllConversations.defaultExpectation.paramPtrs == nil { + mmGetAllConversations.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllConversationsParamPtrs{} + } + mmGetAllConversations.defaultExpectation.paramPtrs.ticketID = &ticketID + + return mmGetAllConversations +} + +// ExpectPaginationParam2 sets up expected param pagination for FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) ExpectPaginationParam2(pagination bool) *mFreshdeskInterfaceMockGetAllConversations { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + if mmGetAllConversations.defaultExpectation == nil { + mmGetAllConversations.defaultExpectation = &FreshdeskInterfaceMockGetAllConversationsExpectation{} + } + + if mmGetAllConversations.defaultExpectation.params != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Expect") + } + + if mmGetAllConversations.defaultExpectation.paramPtrs == nil { + mmGetAllConversations.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllConversationsParamPtrs{} + } + mmGetAllConversations.defaultExpectation.paramPtrs.pagination = &pagination + + return mmGetAllConversations +} + +// ExpectPaginationPathParam3 sets up expected param paginationPath for FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) ExpectPaginationPathParam3(paginationPath string) *mFreshdeskInterfaceMockGetAllConversations { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + if mmGetAllConversations.defaultExpectation == nil { + mmGetAllConversations.defaultExpectation = &FreshdeskInterfaceMockGetAllConversationsExpectation{} + } + + if mmGetAllConversations.defaultExpectation.params != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Expect") + } + + if mmGetAllConversations.defaultExpectation.paramPtrs == nil { + mmGetAllConversations.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetAllConversationsParamPtrs{} + } + mmGetAllConversations.defaultExpectation.paramPtrs.paginationPath = &paginationPath + + return mmGetAllConversations +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Inspect(f func(ticketID int64, pagination bool, paginationPath string)) *mFreshdeskInterfaceMockGetAllConversations { + if mmGetAllConversations.mock.inspectFuncGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetAllConversations") + } + + mmGetAllConversations.mock.inspectFuncGetAllConversations = f + + return mmGetAllConversations +} + +// Return sets up results that will be returned by FreshdeskInterface.GetAllConversations +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Return(ta1 []TaskGetAllConversationsResponse, s1 string, err error) *FreshdeskInterfaceMock { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + if mmGetAllConversations.defaultExpectation == nil { + mmGetAllConversations.defaultExpectation = &FreshdeskInterfaceMockGetAllConversationsExpectation{mock: mmGetAllConversations.mock} + } + mmGetAllConversations.defaultExpectation.results = &FreshdeskInterfaceMockGetAllConversationsResults{ta1, s1, err} + return mmGetAllConversations.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetAllConversations method +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Set(f func(ticketID int64, pagination bool, paginationPath string) (ta1 []TaskGetAllConversationsResponse, s1 string, err error)) *FreshdeskInterfaceMock { + if mmGetAllConversations.defaultExpectation != nil { + mmGetAllConversations.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetAllConversations method") + } + + if len(mmGetAllConversations.expectations) > 0 { + mmGetAllConversations.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetAllConversations method") + } + + mmGetAllConversations.mock.funcGetAllConversations = f + return mmGetAllConversations.mock +} + +// When sets expectation for the FreshdeskInterface.GetAllConversations which will trigger the result defined by the following +// Then helper +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) When(ticketID int64, pagination bool, paginationPath string) *FreshdeskInterfaceMockGetAllConversationsExpectation { + if mmGetAllConversations.mock.funcGetAllConversations != nil { + mmGetAllConversations.mock.t.Fatalf("FreshdeskInterfaceMock.GetAllConversations mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetAllConversationsExpectation{ + mock: mmGetAllConversations.mock, + params: &FreshdeskInterfaceMockGetAllConversationsParams{ticketID, pagination, paginationPath}, + } + mmGetAllConversations.expectations = append(mmGetAllConversations.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetAllConversations return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetAllConversationsExpectation) Then(ta1 []TaskGetAllConversationsResponse, s1 string, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetAllConversationsResults{ta1, s1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetAllConversations should be invoked +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Times(n uint64) *mFreshdeskInterfaceMockGetAllConversations { + if n == 0 { + mmGetAllConversations.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetAllConversations mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetAllConversations.expectedInvocations, n) + return mmGetAllConversations +} + +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) invocationsDone() bool { + if len(mmGetAllConversations.expectations) == 0 && mmGetAllConversations.defaultExpectation == nil && mmGetAllConversations.mock.funcGetAllConversations == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetAllConversations.mock.afterGetAllConversationsCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetAllConversations.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetAllConversations implements FreshdeskInterface +func (mmGetAllConversations *FreshdeskInterfaceMock) GetAllConversations(ticketID int64, pagination bool, paginationPath string) (ta1 []TaskGetAllConversationsResponse, s1 string, err error) { + mm_atomic.AddUint64(&mmGetAllConversations.beforeGetAllConversationsCounter, 1) + defer mm_atomic.AddUint64(&mmGetAllConversations.afterGetAllConversationsCounter, 1) + + if mmGetAllConversations.inspectFuncGetAllConversations != nil { + mmGetAllConversations.inspectFuncGetAllConversations(ticketID, pagination, paginationPath) + } + + mm_params := FreshdeskInterfaceMockGetAllConversationsParams{ticketID, pagination, paginationPath} + + // Record call args + mmGetAllConversations.GetAllConversationsMock.mutex.Lock() + mmGetAllConversations.GetAllConversationsMock.callArgs = append(mmGetAllConversations.GetAllConversationsMock.callArgs, &mm_params) + mmGetAllConversations.GetAllConversationsMock.mutex.Unlock() + + for _, e := range mmGetAllConversations.GetAllConversationsMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.ta1, e.results.s1, e.results.err + } + } + + if mmGetAllConversations.GetAllConversationsMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetAllConversations.GetAllConversationsMock.defaultExpectation.Counter, 1) + mm_want := mmGetAllConversations.GetAllConversationsMock.defaultExpectation.params + mm_want_ptrs := mmGetAllConversations.GetAllConversationsMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetAllConversationsParams{ticketID, pagination, paginationPath} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ticketID != nil && !minimock.Equal(*mm_want_ptrs.ticketID, mm_got.ticketID) { + mmGetAllConversations.t.Errorf("FreshdeskInterfaceMock.GetAllConversations got unexpected parameter ticketID, want: %#v, got: %#v%s\n", *mm_want_ptrs.ticketID, mm_got.ticketID, minimock.Diff(*mm_want_ptrs.ticketID, mm_got.ticketID)) + } + + if mm_want_ptrs.pagination != nil && !minimock.Equal(*mm_want_ptrs.pagination, mm_got.pagination) { + mmGetAllConversations.t.Errorf("FreshdeskInterfaceMock.GetAllConversations got unexpected parameter pagination, want: %#v, got: %#v%s\n", *mm_want_ptrs.pagination, mm_got.pagination, minimock.Diff(*mm_want_ptrs.pagination, mm_got.pagination)) + } + + if mm_want_ptrs.paginationPath != nil && !minimock.Equal(*mm_want_ptrs.paginationPath, mm_got.paginationPath) { + mmGetAllConversations.t.Errorf("FreshdeskInterfaceMock.GetAllConversations got unexpected parameter paginationPath, want: %#v, got: %#v%s\n", *mm_want_ptrs.paginationPath, mm_got.paginationPath, minimock.Diff(*mm_want_ptrs.paginationPath, mm_got.paginationPath)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetAllConversations.t.Errorf("FreshdeskInterfaceMock.GetAllConversations got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetAllConversations.GetAllConversationsMock.defaultExpectation.results + if mm_results == nil { + mmGetAllConversations.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetAllConversations") + } + return (*mm_results).ta1, (*mm_results).s1, (*mm_results).err + } + if mmGetAllConversations.funcGetAllConversations != nil { + return mmGetAllConversations.funcGetAllConversations(ticketID, pagination, paginationPath) + } + mmGetAllConversations.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetAllConversations. %v %v %v", ticketID, pagination, paginationPath) + return +} + +// GetAllConversationsAfterCounter returns a count of finished FreshdeskInterfaceMock.GetAllConversations invocations +func (mmGetAllConversations *FreshdeskInterfaceMock) GetAllConversationsAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAllConversations.afterGetAllConversationsCounter) +} + +// GetAllConversationsBeforeCounter returns a count of FreshdeskInterfaceMock.GetAllConversations invocations +func (mmGetAllConversations *FreshdeskInterfaceMock) GetAllConversationsBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetAllConversations.beforeGetAllConversationsCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetAllConversations. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetAllConversations *mFreshdeskInterfaceMockGetAllConversations) Calls() []*FreshdeskInterfaceMockGetAllConversationsParams { + mmGetAllConversations.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetAllConversationsParams, len(mmGetAllConversations.callArgs)) + copy(argCopy, mmGetAllConversations.callArgs) + + mmGetAllConversations.mutex.RUnlock() + + return argCopy +} + +// MinimockGetAllConversationsDone returns true if the count of the GetAllConversations invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetAllConversationsDone() bool { + if m.GetAllConversationsMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetAllConversationsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetAllConversationsMock.invocationsDone() +} + +// MinimockGetAllConversationsInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetAllConversationsInspect() { + for _, e := range m.GetAllConversationsMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAllConversations with params: %#v", *e.params) + } + } + + afterGetAllConversationsCounter := mm_atomic.LoadUint64(&m.afterGetAllConversationsCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetAllConversationsMock.defaultExpectation != nil && afterGetAllConversationsCounter < 1 { + if m.GetAllConversationsMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAllConversations") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetAllConversations with params: %#v", *m.GetAllConversationsMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetAllConversations != nil && afterGetAllConversationsCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetAllConversations") + } + + if !m.GetAllConversationsMock.invocationsDone() && afterGetAllConversationsCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetAllConversations but found %d calls", + mm_atomic.LoadUint64(&m.GetAllConversationsMock.expectedInvocations), afterGetAllConversationsCounter) + } +} + +type mFreshdeskInterfaceMockGetCompany struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetCompanyExpectation + expectations []*FreshdeskInterfaceMockGetCompanyExpectation + + callArgs []*FreshdeskInterfaceMockGetCompanyParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetCompanyExpectation specifies expectation struct of the FreshdeskInterface.GetCompany +type FreshdeskInterfaceMockGetCompanyExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetCompanyParams + paramPtrs *FreshdeskInterfaceMockGetCompanyParamPtrs + results *FreshdeskInterfaceMockGetCompanyResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetCompanyParams contains parameters of the FreshdeskInterface.GetCompany +type FreshdeskInterfaceMockGetCompanyParams struct { + companyID int64 +} + +// FreshdeskInterfaceMockGetCompanyParamPtrs contains pointers to parameters of the FreshdeskInterface.GetCompany +type FreshdeskInterfaceMockGetCompanyParamPtrs struct { + companyID *int64 +} + +// FreshdeskInterfaceMockGetCompanyResults contains results of the FreshdeskInterface.GetCompany +type FreshdeskInterfaceMockGetCompanyResults struct { + tp1 *TaskGetCompanyResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Optional() *mFreshdeskInterfaceMockGetCompany { + mmGetCompany.optional = true + return mmGetCompany +} + +// Expect sets up expected params for FreshdeskInterface.GetCompany +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Expect(companyID int64) *mFreshdeskInterfaceMockGetCompany { + if mmGetCompany.mock.funcGetCompany != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by Set") + } + + if mmGetCompany.defaultExpectation == nil { + mmGetCompany.defaultExpectation = &FreshdeskInterfaceMockGetCompanyExpectation{} + } + + if mmGetCompany.defaultExpectation.paramPtrs != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by ExpectParams functions") + } + + mmGetCompany.defaultExpectation.params = &FreshdeskInterfaceMockGetCompanyParams{companyID} + for _, e := range mmGetCompany.expectations { + if minimock.Equal(e.params, mmGetCompany.defaultExpectation.params) { + mmGetCompany.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetCompany.defaultExpectation.params) + } + } + + return mmGetCompany +} + +// ExpectCompanyIDParam1 sets up expected param companyID for FreshdeskInterface.GetCompany +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) ExpectCompanyIDParam1(companyID int64) *mFreshdeskInterfaceMockGetCompany { + if mmGetCompany.mock.funcGetCompany != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by Set") + } + + if mmGetCompany.defaultExpectation == nil { + mmGetCompany.defaultExpectation = &FreshdeskInterfaceMockGetCompanyExpectation{} + } + + if mmGetCompany.defaultExpectation.params != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by Expect") + } + + if mmGetCompany.defaultExpectation.paramPtrs == nil { + mmGetCompany.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetCompanyParamPtrs{} + } + mmGetCompany.defaultExpectation.paramPtrs.companyID = &companyID + + return mmGetCompany +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetCompany +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Inspect(f func(companyID int64)) *mFreshdeskInterfaceMockGetCompany { + if mmGetCompany.mock.inspectFuncGetCompany != nil { + mmGetCompany.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetCompany") + } + + mmGetCompany.mock.inspectFuncGetCompany = f + + return mmGetCompany +} + +// Return sets up results that will be returned by FreshdeskInterface.GetCompany +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Return(tp1 *TaskGetCompanyResponse, err error) *FreshdeskInterfaceMock { + if mmGetCompany.mock.funcGetCompany != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by Set") + } + + if mmGetCompany.defaultExpectation == nil { + mmGetCompany.defaultExpectation = &FreshdeskInterfaceMockGetCompanyExpectation{mock: mmGetCompany.mock} + } + mmGetCompany.defaultExpectation.results = &FreshdeskInterfaceMockGetCompanyResults{tp1, err} + return mmGetCompany.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetCompany method +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Set(f func(companyID int64) (tp1 *TaskGetCompanyResponse, err error)) *FreshdeskInterfaceMock { + if mmGetCompany.defaultExpectation != nil { + mmGetCompany.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetCompany method") + } + + if len(mmGetCompany.expectations) > 0 { + mmGetCompany.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetCompany method") + } + + mmGetCompany.mock.funcGetCompany = f + return mmGetCompany.mock +} + +// When sets expectation for the FreshdeskInterface.GetCompany which will trigger the result defined by the following +// Then helper +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) When(companyID int64) *FreshdeskInterfaceMockGetCompanyExpectation { + if mmGetCompany.mock.funcGetCompany != nil { + mmGetCompany.mock.t.Fatalf("FreshdeskInterfaceMock.GetCompany mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetCompanyExpectation{ + mock: mmGetCompany.mock, + params: &FreshdeskInterfaceMockGetCompanyParams{companyID}, + } + mmGetCompany.expectations = append(mmGetCompany.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetCompany return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetCompanyExpectation) Then(tp1 *TaskGetCompanyResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetCompanyResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetCompany should be invoked +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Times(n uint64) *mFreshdeskInterfaceMockGetCompany { + if n == 0 { + mmGetCompany.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetCompany mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetCompany.expectedInvocations, n) + return mmGetCompany +} + +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) invocationsDone() bool { + if len(mmGetCompany.expectations) == 0 && mmGetCompany.defaultExpectation == nil && mmGetCompany.mock.funcGetCompany == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetCompany.mock.afterGetCompanyCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetCompany.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetCompany implements FreshdeskInterface +func (mmGetCompany *FreshdeskInterfaceMock) GetCompany(companyID int64) (tp1 *TaskGetCompanyResponse, err error) { + mm_atomic.AddUint64(&mmGetCompany.beforeGetCompanyCounter, 1) + defer mm_atomic.AddUint64(&mmGetCompany.afterGetCompanyCounter, 1) + + if mmGetCompany.inspectFuncGetCompany != nil { + mmGetCompany.inspectFuncGetCompany(companyID) + } + + mm_params := FreshdeskInterfaceMockGetCompanyParams{companyID} + + // Record call args + mmGetCompany.GetCompanyMock.mutex.Lock() + mmGetCompany.GetCompanyMock.callArgs = append(mmGetCompany.GetCompanyMock.callArgs, &mm_params) + mmGetCompany.GetCompanyMock.mutex.Unlock() + + for _, e := range mmGetCompany.GetCompanyMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetCompany.GetCompanyMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetCompany.GetCompanyMock.defaultExpectation.Counter, 1) + mm_want := mmGetCompany.GetCompanyMock.defaultExpectation.params + mm_want_ptrs := mmGetCompany.GetCompanyMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetCompanyParams{companyID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.companyID != nil && !minimock.Equal(*mm_want_ptrs.companyID, mm_got.companyID) { + mmGetCompany.t.Errorf("FreshdeskInterfaceMock.GetCompany got unexpected parameter companyID, want: %#v, got: %#v%s\n", *mm_want_ptrs.companyID, mm_got.companyID, minimock.Diff(*mm_want_ptrs.companyID, mm_got.companyID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetCompany.t.Errorf("FreshdeskInterfaceMock.GetCompany got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetCompany.GetCompanyMock.defaultExpectation.results + if mm_results == nil { + mmGetCompany.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetCompany") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetCompany.funcGetCompany != nil { + return mmGetCompany.funcGetCompany(companyID) + } + mmGetCompany.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetCompany. %v", companyID) + return +} + +// GetCompanyAfterCounter returns a count of finished FreshdeskInterfaceMock.GetCompany invocations +func (mmGetCompany *FreshdeskInterfaceMock) GetCompanyAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetCompany.afterGetCompanyCounter) +} + +// GetCompanyBeforeCounter returns a count of FreshdeskInterfaceMock.GetCompany invocations +func (mmGetCompany *FreshdeskInterfaceMock) GetCompanyBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetCompany.beforeGetCompanyCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetCompany. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetCompany *mFreshdeskInterfaceMockGetCompany) Calls() []*FreshdeskInterfaceMockGetCompanyParams { + mmGetCompany.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetCompanyParams, len(mmGetCompany.callArgs)) + copy(argCopy, mmGetCompany.callArgs) + + mmGetCompany.mutex.RUnlock() + + return argCopy +} + +// MinimockGetCompanyDone returns true if the count of the GetCompany invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetCompanyDone() bool { + if m.GetCompanyMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetCompanyMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetCompanyMock.invocationsDone() +} + +// MinimockGetCompanyInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetCompanyInspect() { + for _, e := range m.GetCompanyMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetCompany with params: %#v", *e.params) + } + } + + afterGetCompanyCounter := mm_atomic.LoadUint64(&m.afterGetCompanyCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetCompanyMock.defaultExpectation != nil && afterGetCompanyCounter < 1 { + if m.GetCompanyMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetCompany") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetCompany with params: %#v", *m.GetCompanyMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetCompany != nil && afterGetCompanyCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetCompany") + } + + if !m.GetCompanyMock.invocationsDone() && afterGetCompanyCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetCompany but found %d calls", + mm_atomic.LoadUint64(&m.GetCompanyMock.expectedInvocations), afterGetCompanyCounter) + } +} + +type mFreshdeskInterfaceMockGetContact struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetContactExpectation + expectations []*FreshdeskInterfaceMockGetContactExpectation + + callArgs []*FreshdeskInterfaceMockGetContactParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetContactExpectation specifies expectation struct of the FreshdeskInterface.GetContact +type FreshdeskInterfaceMockGetContactExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetContactParams + paramPtrs *FreshdeskInterfaceMockGetContactParamPtrs + results *FreshdeskInterfaceMockGetContactResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetContactParams contains parameters of the FreshdeskInterface.GetContact +type FreshdeskInterfaceMockGetContactParams struct { + contactID int64 +} + +// FreshdeskInterfaceMockGetContactParamPtrs contains pointers to parameters of the FreshdeskInterface.GetContact +type FreshdeskInterfaceMockGetContactParamPtrs struct { + contactID *int64 +} + +// FreshdeskInterfaceMockGetContactResults contains results of the FreshdeskInterface.GetContact +type FreshdeskInterfaceMockGetContactResults struct { + tp1 *TaskGetContactResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Optional() *mFreshdeskInterfaceMockGetContact { + mmGetContact.optional = true + return mmGetContact +} + +// Expect sets up expected params for FreshdeskInterface.GetContact +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Expect(contactID int64) *mFreshdeskInterfaceMockGetContact { + if mmGetContact.mock.funcGetContact != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by Set") + } + + if mmGetContact.defaultExpectation == nil { + mmGetContact.defaultExpectation = &FreshdeskInterfaceMockGetContactExpectation{} + } + + if mmGetContact.defaultExpectation.paramPtrs != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by ExpectParams functions") + } + + mmGetContact.defaultExpectation.params = &FreshdeskInterfaceMockGetContactParams{contactID} + for _, e := range mmGetContact.expectations { + if minimock.Equal(e.params, mmGetContact.defaultExpectation.params) { + mmGetContact.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetContact.defaultExpectation.params) + } + } + + return mmGetContact +} + +// ExpectContactIDParam1 sets up expected param contactID for FreshdeskInterface.GetContact +func (mmGetContact *mFreshdeskInterfaceMockGetContact) ExpectContactIDParam1(contactID int64) *mFreshdeskInterfaceMockGetContact { + if mmGetContact.mock.funcGetContact != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by Set") + } + + if mmGetContact.defaultExpectation == nil { + mmGetContact.defaultExpectation = &FreshdeskInterfaceMockGetContactExpectation{} + } + + if mmGetContact.defaultExpectation.params != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by Expect") + } + + if mmGetContact.defaultExpectation.paramPtrs == nil { + mmGetContact.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetContactParamPtrs{} + } + mmGetContact.defaultExpectation.paramPtrs.contactID = &contactID + + return mmGetContact +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetContact +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Inspect(f func(contactID int64)) *mFreshdeskInterfaceMockGetContact { + if mmGetContact.mock.inspectFuncGetContact != nil { + mmGetContact.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetContact") + } + + mmGetContact.mock.inspectFuncGetContact = f + + return mmGetContact +} + +// Return sets up results that will be returned by FreshdeskInterface.GetContact +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Return(tp1 *TaskGetContactResponse, err error) *FreshdeskInterfaceMock { + if mmGetContact.mock.funcGetContact != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by Set") + } + + if mmGetContact.defaultExpectation == nil { + mmGetContact.defaultExpectation = &FreshdeskInterfaceMockGetContactExpectation{mock: mmGetContact.mock} + } + mmGetContact.defaultExpectation.results = &FreshdeskInterfaceMockGetContactResults{tp1, err} + return mmGetContact.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetContact method +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Set(f func(contactID int64) (tp1 *TaskGetContactResponse, err error)) *FreshdeskInterfaceMock { + if mmGetContact.defaultExpectation != nil { + mmGetContact.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetContact method") + } + + if len(mmGetContact.expectations) > 0 { + mmGetContact.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetContact method") + } + + mmGetContact.mock.funcGetContact = f + return mmGetContact.mock +} + +// When sets expectation for the FreshdeskInterface.GetContact which will trigger the result defined by the following +// Then helper +func (mmGetContact *mFreshdeskInterfaceMockGetContact) When(contactID int64) *FreshdeskInterfaceMockGetContactExpectation { + if mmGetContact.mock.funcGetContact != nil { + mmGetContact.mock.t.Fatalf("FreshdeskInterfaceMock.GetContact mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetContactExpectation{ + mock: mmGetContact.mock, + params: &FreshdeskInterfaceMockGetContactParams{contactID}, + } + mmGetContact.expectations = append(mmGetContact.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetContact return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetContactExpectation) Then(tp1 *TaskGetContactResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetContactResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetContact should be invoked +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Times(n uint64) *mFreshdeskInterfaceMockGetContact { + if n == 0 { + mmGetContact.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetContact mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetContact.expectedInvocations, n) + return mmGetContact +} + +func (mmGetContact *mFreshdeskInterfaceMockGetContact) invocationsDone() bool { + if len(mmGetContact.expectations) == 0 && mmGetContact.defaultExpectation == nil && mmGetContact.mock.funcGetContact == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetContact.mock.afterGetContactCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetContact.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetContact implements FreshdeskInterface +func (mmGetContact *FreshdeskInterfaceMock) GetContact(contactID int64) (tp1 *TaskGetContactResponse, err error) { + mm_atomic.AddUint64(&mmGetContact.beforeGetContactCounter, 1) + defer mm_atomic.AddUint64(&mmGetContact.afterGetContactCounter, 1) + + if mmGetContact.inspectFuncGetContact != nil { + mmGetContact.inspectFuncGetContact(contactID) + } + + mm_params := FreshdeskInterfaceMockGetContactParams{contactID} + + // Record call args + mmGetContact.GetContactMock.mutex.Lock() + mmGetContact.GetContactMock.callArgs = append(mmGetContact.GetContactMock.callArgs, &mm_params) + mmGetContact.GetContactMock.mutex.Unlock() + + for _, e := range mmGetContact.GetContactMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetContact.GetContactMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetContact.GetContactMock.defaultExpectation.Counter, 1) + mm_want := mmGetContact.GetContactMock.defaultExpectation.params + mm_want_ptrs := mmGetContact.GetContactMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetContactParams{contactID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.contactID != nil && !minimock.Equal(*mm_want_ptrs.contactID, mm_got.contactID) { + mmGetContact.t.Errorf("FreshdeskInterfaceMock.GetContact got unexpected parameter contactID, want: %#v, got: %#v%s\n", *mm_want_ptrs.contactID, mm_got.contactID, minimock.Diff(*mm_want_ptrs.contactID, mm_got.contactID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetContact.t.Errorf("FreshdeskInterfaceMock.GetContact got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetContact.GetContactMock.defaultExpectation.results + if mm_results == nil { + mmGetContact.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetContact") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetContact.funcGetContact != nil { + return mmGetContact.funcGetContact(contactID) + } + mmGetContact.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetContact. %v", contactID) + return +} + +// GetContactAfterCounter returns a count of finished FreshdeskInterfaceMock.GetContact invocations +func (mmGetContact *FreshdeskInterfaceMock) GetContactAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetContact.afterGetContactCounter) +} + +// GetContactBeforeCounter returns a count of FreshdeskInterfaceMock.GetContact invocations +func (mmGetContact *FreshdeskInterfaceMock) GetContactBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetContact.beforeGetContactCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetContact. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetContact *mFreshdeskInterfaceMockGetContact) Calls() []*FreshdeskInterfaceMockGetContactParams { + mmGetContact.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetContactParams, len(mmGetContact.callArgs)) + copy(argCopy, mmGetContact.callArgs) + + mmGetContact.mutex.RUnlock() + + return argCopy +} + +// MinimockGetContactDone returns true if the count of the GetContact invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetContactDone() bool { + if m.GetContactMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetContactMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetContactMock.invocationsDone() +} + +// MinimockGetContactInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetContactInspect() { + for _, e := range m.GetContactMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetContact with params: %#v", *e.params) + } + } + + afterGetContactCounter := mm_atomic.LoadUint64(&m.afterGetContactCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetContactMock.defaultExpectation != nil && afterGetContactCounter < 1 { + if m.GetContactMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetContact") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetContact with params: %#v", *m.GetContactMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetContact != nil && afterGetContactCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetContact") + } + + if !m.GetContactMock.invocationsDone() && afterGetContactCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetContact but found %d calls", + mm_atomic.LoadUint64(&m.GetContactMock.expectedInvocations), afterGetContactCounter) + } +} + +type mFreshdeskInterfaceMockGetGroup struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetGroupExpectation + expectations []*FreshdeskInterfaceMockGetGroupExpectation + + callArgs []*FreshdeskInterfaceMockGetGroupParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetGroupExpectation specifies expectation struct of the FreshdeskInterface.GetGroup +type FreshdeskInterfaceMockGetGroupExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetGroupParams + paramPtrs *FreshdeskInterfaceMockGetGroupParamPtrs + results *FreshdeskInterfaceMockGetGroupResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetGroupParams contains parameters of the FreshdeskInterface.GetGroup +type FreshdeskInterfaceMockGetGroupParams struct { + groupID int64 +} + +// FreshdeskInterfaceMockGetGroupParamPtrs contains pointers to parameters of the FreshdeskInterface.GetGroup +type FreshdeskInterfaceMockGetGroupParamPtrs struct { + groupID *int64 +} + +// FreshdeskInterfaceMockGetGroupResults contains results of the FreshdeskInterface.GetGroup +type FreshdeskInterfaceMockGetGroupResults struct { + tp1 *TaskGetGroupResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Optional() *mFreshdeskInterfaceMockGetGroup { + mmGetGroup.optional = true + return mmGetGroup +} + +// Expect sets up expected params for FreshdeskInterface.GetGroup +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Expect(groupID int64) *mFreshdeskInterfaceMockGetGroup { + if mmGetGroup.mock.funcGetGroup != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by Set") + } + + if mmGetGroup.defaultExpectation == nil { + mmGetGroup.defaultExpectation = &FreshdeskInterfaceMockGetGroupExpectation{} + } + + if mmGetGroup.defaultExpectation.paramPtrs != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by ExpectParams functions") + } + + mmGetGroup.defaultExpectation.params = &FreshdeskInterfaceMockGetGroupParams{groupID} + for _, e := range mmGetGroup.expectations { + if minimock.Equal(e.params, mmGetGroup.defaultExpectation.params) { + mmGetGroup.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetGroup.defaultExpectation.params) + } + } + + return mmGetGroup +} + +// ExpectGroupIDParam1 sets up expected param groupID for FreshdeskInterface.GetGroup +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) ExpectGroupIDParam1(groupID int64) *mFreshdeskInterfaceMockGetGroup { + if mmGetGroup.mock.funcGetGroup != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by Set") + } + + if mmGetGroup.defaultExpectation == nil { + mmGetGroup.defaultExpectation = &FreshdeskInterfaceMockGetGroupExpectation{} + } + + if mmGetGroup.defaultExpectation.params != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by Expect") + } + + if mmGetGroup.defaultExpectation.paramPtrs == nil { + mmGetGroup.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetGroupParamPtrs{} + } + mmGetGroup.defaultExpectation.paramPtrs.groupID = &groupID + + return mmGetGroup +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetGroup +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Inspect(f func(groupID int64)) *mFreshdeskInterfaceMockGetGroup { + if mmGetGroup.mock.inspectFuncGetGroup != nil { + mmGetGroup.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetGroup") + } + + mmGetGroup.mock.inspectFuncGetGroup = f + + return mmGetGroup +} + +// Return sets up results that will be returned by FreshdeskInterface.GetGroup +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Return(tp1 *TaskGetGroupResponse, err error) *FreshdeskInterfaceMock { + if mmGetGroup.mock.funcGetGroup != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by Set") + } + + if mmGetGroup.defaultExpectation == nil { + mmGetGroup.defaultExpectation = &FreshdeskInterfaceMockGetGroupExpectation{mock: mmGetGroup.mock} + } + mmGetGroup.defaultExpectation.results = &FreshdeskInterfaceMockGetGroupResults{tp1, err} + return mmGetGroup.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetGroup method +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Set(f func(groupID int64) (tp1 *TaskGetGroupResponse, err error)) *FreshdeskInterfaceMock { + if mmGetGroup.defaultExpectation != nil { + mmGetGroup.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetGroup method") + } + + if len(mmGetGroup.expectations) > 0 { + mmGetGroup.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetGroup method") + } + + mmGetGroup.mock.funcGetGroup = f + return mmGetGroup.mock +} + +// When sets expectation for the FreshdeskInterface.GetGroup which will trigger the result defined by the following +// Then helper +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) When(groupID int64) *FreshdeskInterfaceMockGetGroupExpectation { + if mmGetGroup.mock.funcGetGroup != nil { + mmGetGroup.mock.t.Fatalf("FreshdeskInterfaceMock.GetGroup mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetGroupExpectation{ + mock: mmGetGroup.mock, + params: &FreshdeskInterfaceMockGetGroupParams{groupID}, + } + mmGetGroup.expectations = append(mmGetGroup.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetGroup return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetGroupExpectation) Then(tp1 *TaskGetGroupResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetGroupResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetGroup should be invoked +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Times(n uint64) *mFreshdeskInterfaceMockGetGroup { + if n == 0 { + mmGetGroup.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetGroup mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetGroup.expectedInvocations, n) + return mmGetGroup +} + +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) invocationsDone() bool { + if len(mmGetGroup.expectations) == 0 && mmGetGroup.defaultExpectation == nil && mmGetGroup.mock.funcGetGroup == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetGroup.mock.afterGetGroupCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetGroup.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetGroup implements FreshdeskInterface +func (mmGetGroup *FreshdeskInterfaceMock) GetGroup(groupID int64) (tp1 *TaskGetGroupResponse, err error) { + mm_atomic.AddUint64(&mmGetGroup.beforeGetGroupCounter, 1) + defer mm_atomic.AddUint64(&mmGetGroup.afterGetGroupCounter, 1) + + if mmGetGroup.inspectFuncGetGroup != nil { + mmGetGroup.inspectFuncGetGroup(groupID) + } + + mm_params := FreshdeskInterfaceMockGetGroupParams{groupID} + + // Record call args + mmGetGroup.GetGroupMock.mutex.Lock() + mmGetGroup.GetGroupMock.callArgs = append(mmGetGroup.GetGroupMock.callArgs, &mm_params) + mmGetGroup.GetGroupMock.mutex.Unlock() + + for _, e := range mmGetGroup.GetGroupMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetGroup.GetGroupMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetGroup.GetGroupMock.defaultExpectation.Counter, 1) + mm_want := mmGetGroup.GetGroupMock.defaultExpectation.params + mm_want_ptrs := mmGetGroup.GetGroupMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetGroupParams{groupID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.groupID != nil && !minimock.Equal(*mm_want_ptrs.groupID, mm_got.groupID) { + mmGetGroup.t.Errorf("FreshdeskInterfaceMock.GetGroup got unexpected parameter groupID, want: %#v, got: %#v%s\n", *mm_want_ptrs.groupID, mm_got.groupID, minimock.Diff(*mm_want_ptrs.groupID, mm_got.groupID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetGroup.t.Errorf("FreshdeskInterfaceMock.GetGroup got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetGroup.GetGroupMock.defaultExpectation.results + if mm_results == nil { + mmGetGroup.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetGroup") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetGroup.funcGetGroup != nil { + return mmGetGroup.funcGetGroup(groupID) + } + mmGetGroup.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetGroup. %v", groupID) + return +} + +// GetGroupAfterCounter returns a count of finished FreshdeskInterfaceMock.GetGroup invocations +func (mmGetGroup *FreshdeskInterfaceMock) GetGroupAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetGroup.afterGetGroupCounter) +} + +// GetGroupBeforeCounter returns a count of FreshdeskInterfaceMock.GetGroup invocations +func (mmGetGroup *FreshdeskInterfaceMock) GetGroupBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetGroup.beforeGetGroupCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetGroup. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetGroup *mFreshdeskInterfaceMockGetGroup) Calls() []*FreshdeskInterfaceMockGetGroupParams { + mmGetGroup.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetGroupParams, len(mmGetGroup.callArgs)) + copy(argCopy, mmGetGroup.callArgs) + + mmGetGroup.mutex.RUnlock() + + return argCopy +} + +// MinimockGetGroupDone returns true if the count of the GetGroup invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetGroupDone() bool { + if m.GetGroupMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetGroupMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetGroupMock.invocationsDone() +} + +// MinimockGetGroupInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetGroupInspect() { + for _, e := range m.GetGroupMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetGroup with params: %#v", *e.params) + } + } + + afterGetGroupCounter := mm_atomic.LoadUint64(&m.afterGetGroupCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetGroupMock.defaultExpectation != nil && afterGetGroupCounter < 1 { + if m.GetGroupMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetGroup") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetGroup with params: %#v", *m.GetGroupMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetGroup != nil && afterGetGroupCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetGroup") + } + + if !m.GetGroupMock.invocationsDone() && afterGetGroupCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetGroup but found %d calls", + mm_atomic.LoadUint64(&m.GetGroupMock.expectedInvocations), afterGetGroupCounter) + } +} + +type mFreshdeskInterfaceMockGetProduct struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetProductExpectation + expectations []*FreshdeskInterfaceMockGetProductExpectation + + callArgs []*FreshdeskInterfaceMockGetProductParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetProductExpectation specifies expectation struct of the FreshdeskInterface.GetProduct +type FreshdeskInterfaceMockGetProductExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetProductParams + paramPtrs *FreshdeskInterfaceMockGetProductParamPtrs + results *FreshdeskInterfaceMockGetProductResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetProductParams contains parameters of the FreshdeskInterface.GetProduct +type FreshdeskInterfaceMockGetProductParams struct { + productID int64 +} + +// FreshdeskInterfaceMockGetProductParamPtrs contains pointers to parameters of the FreshdeskInterface.GetProduct +type FreshdeskInterfaceMockGetProductParamPtrs struct { + productID *int64 +} + +// FreshdeskInterfaceMockGetProductResults contains results of the FreshdeskInterface.GetProduct +type FreshdeskInterfaceMockGetProductResults struct { + tp1 *TaskGetProductResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Optional() *mFreshdeskInterfaceMockGetProduct { + mmGetProduct.optional = true + return mmGetProduct +} + +// Expect sets up expected params for FreshdeskInterface.GetProduct +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Expect(productID int64) *mFreshdeskInterfaceMockGetProduct { + if mmGetProduct.mock.funcGetProduct != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by Set") + } + + if mmGetProduct.defaultExpectation == nil { + mmGetProduct.defaultExpectation = &FreshdeskInterfaceMockGetProductExpectation{} + } + + if mmGetProduct.defaultExpectation.paramPtrs != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by ExpectParams functions") + } + + mmGetProduct.defaultExpectation.params = &FreshdeskInterfaceMockGetProductParams{productID} + for _, e := range mmGetProduct.expectations { + if minimock.Equal(e.params, mmGetProduct.defaultExpectation.params) { + mmGetProduct.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetProduct.defaultExpectation.params) + } + } + + return mmGetProduct +} + +// ExpectProductIDParam1 sets up expected param productID for FreshdeskInterface.GetProduct +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) ExpectProductIDParam1(productID int64) *mFreshdeskInterfaceMockGetProduct { + if mmGetProduct.mock.funcGetProduct != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by Set") + } + + if mmGetProduct.defaultExpectation == nil { + mmGetProduct.defaultExpectation = &FreshdeskInterfaceMockGetProductExpectation{} + } + + if mmGetProduct.defaultExpectation.params != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by Expect") + } + + if mmGetProduct.defaultExpectation.paramPtrs == nil { + mmGetProduct.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetProductParamPtrs{} + } + mmGetProduct.defaultExpectation.paramPtrs.productID = &productID + + return mmGetProduct +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetProduct +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Inspect(f func(productID int64)) *mFreshdeskInterfaceMockGetProduct { + if mmGetProduct.mock.inspectFuncGetProduct != nil { + mmGetProduct.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetProduct") + } + + mmGetProduct.mock.inspectFuncGetProduct = f + + return mmGetProduct +} + +// Return sets up results that will be returned by FreshdeskInterface.GetProduct +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Return(tp1 *TaskGetProductResponse, err error) *FreshdeskInterfaceMock { + if mmGetProduct.mock.funcGetProduct != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by Set") + } + + if mmGetProduct.defaultExpectation == nil { + mmGetProduct.defaultExpectation = &FreshdeskInterfaceMockGetProductExpectation{mock: mmGetProduct.mock} + } + mmGetProduct.defaultExpectation.results = &FreshdeskInterfaceMockGetProductResults{tp1, err} + return mmGetProduct.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetProduct method +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Set(f func(productID int64) (tp1 *TaskGetProductResponse, err error)) *FreshdeskInterfaceMock { + if mmGetProduct.defaultExpectation != nil { + mmGetProduct.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetProduct method") + } + + if len(mmGetProduct.expectations) > 0 { + mmGetProduct.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetProduct method") + } + + mmGetProduct.mock.funcGetProduct = f + return mmGetProduct.mock +} + +// When sets expectation for the FreshdeskInterface.GetProduct which will trigger the result defined by the following +// Then helper +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) When(productID int64) *FreshdeskInterfaceMockGetProductExpectation { + if mmGetProduct.mock.funcGetProduct != nil { + mmGetProduct.mock.t.Fatalf("FreshdeskInterfaceMock.GetProduct mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetProductExpectation{ + mock: mmGetProduct.mock, + params: &FreshdeskInterfaceMockGetProductParams{productID}, + } + mmGetProduct.expectations = append(mmGetProduct.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetProduct return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetProductExpectation) Then(tp1 *TaskGetProductResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetProductResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetProduct should be invoked +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Times(n uint64) *mFreshdeskInterfaceMockGetProduct { + if n == 0 { + mmGetProduct.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetProduct mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetProduct.expectedInvocations, n) + return mmGetProduct +} + +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) invocationsDone() bool { + if len(mmGetProduct.expectations) == 0 && mmGetProduct.defaultExpectation == nil && mmGetProduct.mock.funcGetProduct == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetProduct.mock.afterGetProductCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetProduct.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetProduct implements FreshdeskInterface +func (mmGetProduct *FreshdeskInterfaceMock) GetProduct(productID int64) (tp1 *TaskGetProductResponse, err error) { + mm_atomic.AddUint64(&mmGetProduct.beforeGetProductCounter, 1) + defer mm_atomic.AddUint64(&mmGetProduct.afterGetProductCounter, 1) + + if mmGetProduct.inspectFuncGetProduct != nil { + mmGetProduct.inspectFuncGetProduct(productID) + } + + mm_params := FreshdeskInterfaceMockGetProductParams{productID} + + // Record call args + mmGetProduct.GetProductMock.mutex.Lock() + mmGetProduct.GetProductMock.callArgs = append(mmGetProduct.GetProductMock.callArgs, &mm_params) + mmGetProduct.GetProductMock.mutex.Unlock() + + for _, e := range mmGetProduct.GetProductMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetProduct.GetProductMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetProduct.GetProductMock.defaultExpectation.Counter, 1) + mm_want := mmGetProduct.GetProductMock.defaultExpectation.params + mm_want_ptrs := mmGetProduct.GetProductMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetProductParams{productID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.productID != nil && !minimock.Equal(*mm_want_ptrs.productID, mm_got.productID) { + mmGetProduct.t.Errorf("FreshdeskInterfaceMock.GetProduct got unexpected parameter productID, want: %#v, got: %#v%s\n", *mm_want_ptrs.productID, mm_got.productID, minimock.Diff(*mm_want_ptrs.productID, mm_got.productID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetProduct.t.Errorf("FreshdeskInterfaceMock.GetProduct got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetProduct.GetProductMock.defaultExpectation.results + if mm_results == nil { + mmGetProduct.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetProduct") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetProduct.funcGetProduct != nil { + return mmGetProduct.funcGetProduct(productID) + } + mmGetProduct.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetProduct. %v", productID) + return +} + +// GetProductAfterCounter returns a count of finished FreshdeskInterfaceMock.GetProduct invocations +func (mmGetProduct *FreshdeskInterfaceMock) GetProductAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetProduct.afterGetProductCounter) +} + +// GetProductBeforeCounter returns a count of FreshdeskInterfaceMock.GetProduct invocations +func (mmGetProduct *FreshdeskInterfaceMock) GetProductBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetProduct.beforeGetProductCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetProduct. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetProduct *mFreshdeskInterfaceMockGetProduct) Calls() []*FreshdeskInterfaceMockGetProductParams { + mmGetProduct.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetProductParams, len(mmGetProduct.callArgs)) + copy(argCopy, mmGetProduct.callArgs) + + mmGetProduct.mutex.RUnlock() + + return argCopy +} + +// MinimockGetProductDone returns true if the count of the GetProduct invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetProductDone() bool { + if m.GetProductMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetProductMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetProductMock.invocationsDone() +} + +// MinimockGetProductInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetProductInspect() { + for _, e := range m.GetProductMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetProduct with params: %#v", *e.params) + } + } + + afterGetProductCounter := mm_atomic.LoadUint64(&m.afterGetProductCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetProductMock.defaultExpectation != nil && afterGetProductCounter < 1 { + if m.GetProductMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetProduct") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetProduct with params: %#v", *m.GetProductMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetProduct != nil && afterGetProductCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetProduct") + } + + if !m.GetProductMock.invocationsDone() && afterGetProductCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetProduct but found %d calls", + mm_atomic.LoadUint64(&m.GetProductMock.expectedInvocations), afterGetProductCounter) + } +} + +type mFreshdeskInterfaceMockGetRole struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetRoleExpectation + expectations []*FreshdeskInterfaceMockGetRoleExpectation + + callArgs []*FreshdeskInterfaceMockGetRoleParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetRoleExpectation specifies expectation struct of the FreshdeskInterface.GetRole +type FreshdeskInterfaceMockGetRoleExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetRoleParams + paramPtrs *FreshdeskInterfaceMockGetRoleParamPtrs + results *FreshdeskInterfaceMockGetRoleResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetRoleParams contains parameters of the FreshdeskInterface.GetRole +type FreshdeskInterfaceMockGetRoleParams struct { + roleID int64 +} + +// FreshdeskInterfaceMockGetRoleParamPtrs contains pointers to parameters of the FreshdeskInterface.GetRole +type FreshdeskInterfaceMockGetRoleParamPtrs struct { + roleID *int64 +} + +// FreshdeskInterfaceMockGetRoleResults contains results of the FreshdeskInterface.GetRole +type FreshdeskInterfaceMockGetRoleResults struct { + tp1 *TaskGetRoleResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Optional() *mFreshdeskInterfaceMockGetRole { + mmGetRole.optional = true + return mmGetRole +} + +// Expect sets up expected params for FreshdeskInterface.GetRole +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Expect(roleID int64) *mFreshdeskInterfaceMockGetRole { + if mmGetRole.mock.funcGetRole != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by Set") + } + + if mmGetRole.defaultExpectation == nil { + mmGetRole.defaultExpectation = &FreshdeskInterfaceMockGetRoleExpectation{} + } + + if mmGetRole.defaultExpectation.paramPtrs != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by ExpectParams functions") + } + + mmGetRole.defaultExpectation.params = &FreshdeskInterfaceMockGetRoleParams{roleID} + for _, e := range mmGetRole.expectations { + if minimock.Equal(e.params, mmGetRole.defaultExpectation.params) { + mmGetRole.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetRole.defaultExpectation.params) + } + } + + return mmGetRole +} + +// ExpectRoleIDParam1 sets up expected param roleID for FreshdeskInterface.GetRole +func (mmGetRole *mFreshdeskInterfaceMockGetRole) ExpectRoleIDParam1(roleID int64) *mFreshdeskInterfaceMockGetRole { + if mmGetRole.mock.funcGetRole != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by Set") + } + + if mmGetRole.defaultExpectation == nil { + mmGetRole.defaultExpectation = &FreshdeskInterfaceMockGetRoleExpectation{} + } + + if mmGetRole.defaultExpectation.params != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by Expect") + } + + if mmGetRole.defaultExpectation.paramPtrs == nil { + mmGetRole.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetRoleParamPtrs{} + } + mmGetRole.defaultExpectation.paramPtrs.roleID = &roleID + + return mmGetRole +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetRole +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Inspect(f func(roleID int64)) *mFreshdeskInterfaceMockGetRole { + if mmGetRole.mock.inspectFuncGetRole != nil { + mmGetRole.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetRole") + } + + mmGetRole.mock.inspectFuncGetRole = f + + return mmGetRole +} + +// Return sets up results that will be returned by FreshdeskInterface.GetRole +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Return(tp1 *TaskGetRoleResponse, err error) *FreshdeskInterfaceMock { + if mmGetRole.mock.funcGetRole != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by Set") + } + + if mmGetRole.defaultExpectation == nil { + mmGetRole.defaultExpectation = &FreshdeskInterfaceMockGetRoleExpectation{mock: mmGetRole.mock} + } + mmGetRole.defaultExpectation.results = &FreshdeskInterfaceMockGetRoleResults{tp1, err} + return mmGetRole.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetRole method +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Set(f func(roleID int64) (tp1 *TaskGetRoleResponse, err error)) *FreshdeskInterfaceMock { + if mmGetRole.defaultExpectation != nil { + mmGetRole.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetRole method") + } + + if len(mmGetRole.expectations) > 0 { + mmGetRole.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetRole method") + } + + mmGetRole.mock.funcGetRole = f + return mmGetRole.mock +} + +// When sets expectation for the FreshdeskInterface.GetRole which will trigger the result defined by the following +// Then helper +func (mmGetRole *mFreshdeskInterfaceMockGetRole) When(roleID int64) *FreshdeskInterfaceMockGetRoleExpectation { + if mmGetRole.mock.funcGetRole != nil { + mmGetRole.mock.t.Fatalf("FreshdeskInterfaceMock.GetRole mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetRoleExpectation{ + mock: mmGetRole.mock, + params: &FreshdeskInterfaceMockGetRoleParams{roleID}, + } + mmGetRole.expectations = append(mmGetRole.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetRole return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetRoleExpectation) Then(tp1 *TaskGetRoleResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetRoleResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetRole should be invoked +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Times(n uint64) *mFreshdeskInterfaceMockGetRole { + if n == 0 { + mmGetRole.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetRole mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetRole.expectedInvocations, n) + return mmGetRole +} + +func (mmGetRole *mFreshdeskInterfaceMockGetRole) invocationsDone() bool { + if len(mmGetRole.expectations) == 0 && mmGetRole.defaultExpectation == nil && mmGetRole.mock.funcGetRole == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetRole.mock.afterGetRoleCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetRole.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetRole implements FreshdeskInterface +func (mmGetRole *FreshdeskInterfaceMock) GetRole(roleID int64) (tp1 *TaskGetRoleResponse, err error) { + mm_atomic.AddUint64(&mmGetRole.beforeGetRoleCounter, 1) + defer mm_atomic.AddUint64(&mmGetRole.afterGetRoleCounter, 1) + + if mmGetRole.inspectFuncGetRole != nil { + mmGetRole.inspectFuncGetRole(roleID) + } + + mm_params := FreshdeskInterfaceMockGetRoleParams{roleID} + + // Record call args + mmGetRole.GetRoleMock.mutex.Lock() + mmGetRole.GetRoleMock.callArgs = append(mmGetRole.GetRoleMock.callArgs, &mm_params) + mmGetRole.GetRoleMock.mutex.Unlock() + + for _, e := range mmGetRole.GetRoleMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetRole.GetRoleMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetRole.GetRoleMock.defaultExpectation.Counter, 1) + mm_want := mmGetRole.GetRoleMock.defaultExpectation.params + mm_want_ptrs := mmGetRole.GetRoleMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetRoleParams{roleID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.roleID != nil && !minimock.Equal(*mm_want_ptrs.roleID, mm_got.roleID) { + mmGetRole.t.Errorf("FreshdeskInterfaceMock.GetRole got unexpected parameter roleID, want: %#v, got: %#v%s\n", *mm_want_ptrs.roleID, mm_got.roleID, minimock.Diff(*mm_want_ptrs.roleID, mm_got.roleID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetRole.t.Errorf("FreshdeskInterfaceMock.GetRole got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetRole.GetRoleMock.defaultExpectation.results + if mm_results == nil { + mmGetRole.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetRole") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetRole.funcGetRole != nil { + return mmGetRole.funcGetRole(roleID) + } + mmGetRole.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetRole. %v", roleID) + return +} + +// GetRoleAfterCounter returns a count of finished FreshdeskInterfaceMock.GetRole invocations +func (mmGetRole *FreshdeskInterfaceMock) GetRoleAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetRole.afterGetRoleCounter) +} + +// GetRoleBeforeCounter returns a count of FreshdeskInterfaceMock.GetRole invocations +func (mmGetRole *FreshdeskInterfaceMock) GetRoleBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetRole.beforeGetRoleCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetRole. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetRole *mFreshdeskInterfaceMockGetRole) Calls() []*FreshdeskInterfaceMockGetRoleParams { + mmGetRole.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetRoleParams, len(mmGetRole.callArgs)) + copy(argCopy, mmGetRole.callArgs) + + mmGetRole.mutex.RUnlock() + + return argCopy +} + +// MinimockGetRoleDone returns true if the count of the GetRole invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetRoleDone() bool { + if m.GetRoleMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetRoleMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetRoleMock.invocationsDone() +} + +// MinimockGetRoleInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetRoleInspect() { + for _, e := range m.GetRoleMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetRole with params: %#v", *e.params) + } + } + + afterGetRoleCounter := mm_atomic.LoadUint64(&m.afterGetRoleCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetRoleMock.defaultExpectation != nil && afterGetRoleCounter < 1 { + if m.GetRoleMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetRole") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetRole with params: %#v", *m.GetRoleMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetRole != nil && afterGetRoleCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetRole") + } + + if !m.GetRoleMock.invocationsDone() && afterGetRoleCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetRole but found %d calls", + mm_atomic.LoadUint64(&m.GetRoleMock.expectedInvocations), afterGetRoleCounter) + } +} + +type mFreshdeskInterfaceMockGetSkill struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetSkillExpectation + expectations []*FreshdeskInterfaceMockGetSkillExpectation + + callArgs []*FreshdeskInterfaceMockGetSkillParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetSkillExpectation specifies expectation struct of the FreshdeskInterface.GetSkill +type FreshdeskInterfaceMockGetSkillExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetSkillParams + paramPtrs *FreshdeskInterfaceMockGetSkillParamPtrs + results *FreshdeskInterfaceMockGetSkillResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetSkillParams contains parameters of the FreshdeskInterface.GetSkill +type FreshdeskInterfaceMockGetSkillParams struct { + skillID int64 +} + +// FreshdeskInterfaceMockGetSkillParamPtrs contains pointers to parameters of the FreshdeskInterface.GetSkill +type FreshdeskInterfaceMockGetSkillParamPtrs struct { + skillID *int64 +} + +// FreshdeskInterfaceMockGetSkillResults contains results of the FreshdeskInterface.GetSkill +type FreshdeskInterfaceMockGetSkillResults struct { + tp1 *TaskGetSkillResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Optional() *mFreshdeskInterfaceMockGetSkill { + mmGetSkill.optional = true + return mmGetSkill +} + +// Expect sets up expected params for FreshdeskInterface.GetSkill +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Expect(skillID int64) *mFreshdeskInterfaceMockGetSkill { + if mmGetSkill.mock.funcGetSkill != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by Set") + } + + if mmGetSkill.defaultExpectation == nil { + mmGetSkill.defaultExpectation = &FreshdeskInterfaceMockGetSkillExpectation{} + } + + if mmGetSkill.defaultExpectation.paramPtrs != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by ExpectParams functions") + } + + mmGetSkill.defaultExpectation.params = &FreshdeskInterfaceMockGetSkillParams{skillID} + for _, e := range mmGetSkill.expectations { + if minimock.Equal(e.params, mmGetSkill.defaultExpectation.params) { + mmGetSkill.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetSkill.defaultExpectation.params) + } + } + + return mmGetSkill +} + +// ExpectSkillIDParam1 sets up expected param skillID for FreshdeskInterface.GetSkill +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) ExpectSkillIDParam1(skillID int64) *mFreshdeskInterfaceMockGetSkill { + if mmGetSkill.mock.funcGetSkill != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by Set") + } + + if mmGetSkill.defaultExpectation == nil { + mmGetSkill.defaultExpectation = &FreshdeskInterfaceMockGetSkillExpectation{} + } + + if mmGetSkill.defaultExpectation.params != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by Expect") + } + + if mmGetSkill.defaultExpectation.paramPtrs == nil { + mmGetSkill.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetSkillParamPtrs{} + } + mmGetSkill.defaultExpectation.paramPtrs.skillID = &skillID + + return mmGetSkill +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetSkill +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Inspect(f func(skillID int64)) *mFreshdeskInterfaceMockGetSkill { + if mmGetSkill.mock.inspectFuncGetSkill != nil { + mmGetSkill.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetSkill") + } + + mmGetSkill.mock.inspectFuncGetSkill = f + + return mmGetSkill +} + +// Return sets up results that will be returned by FreshdeskInterface.GetSkill +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Return(tp1 *TaskGetSkillResponse, err error) *FreshdeskInterfaceMock { + if mmGetSkill.mock.funcGetSkill != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by Set") + } + + if mmGetSkill.defaultExpectation == nil { + mmGetSkill.defaultExpectation = &FreshdeskInterfaceMockGetSkillExpectation{mock: mmGetSkill.mock} + } + mmGetSkill.defaultExpectation.results = &FreshdeskInterfaceMockGetSkillResults{tp1, err} + return mmGetSkill.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetSkill method +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Set(f func(skillID int64) (tp1 *TaskGetSkillResponse, err error)) *FreshdeskInterfaceMock { + if mmGetSkill.defaultExpectation != nil { + mmGetSkill.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetSkill method") + } + + if len(mmGetSkill.expectations) > 0 { + mmGetSkill.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetSkill method") + } + + mmGetSkill.mock.funcGetSkill = f + return mmGetSkill.mock +} + +// When sets expectation for the FreshdeskInterface.GetSkill which will trigger the result defined by the following +// Then helper +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) When(skillID int64) *FreshdeskInterfaceMockGetSkillExpectation { + if mmGetSkill.mock.funcGetSkill != nil { + mmGetSkill.mock.t.Fatalf("FreshdeskInterfaceMock.GetSkill mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetSkillExpectation{ + mock: mmGetSkill.mock, + params: &FreshdeskInterfaceMockGetSkillParams{skillID}, + } + mmGetSkill.expectations = append(mmGetSkill.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetSkill return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetSkillExpectation) Then(tp1 *TaskGetSkillResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetSkillResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetSkill should be invoked +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Times(n uint64) *mFreshdeskInterfaceMockGetSkill { + if n == 0 { + mmGetSkill.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetSkill mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetSkill.expectedInvocations, n) + return mmGetSkill +} + +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) invocationsDone() bool { + if len(mmGetSkill.expectations) == 0 && mmGetSkill.defaultExpectation == nil && mmGetSkill.mock.funcGetSkill == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetSkill.mock.afterGetSkillCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetSkill.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetSkill implements FreshdeskInterface +func (mmGetSkill *FreshdeskInterfaceMock) GetSkill(skillID int64) (tp1 *TaskGetSkillResponse, err error) { + mm_atomic.AddUint64(&mmGetSkill.beforeGetSkillCounter, 1) + defer mm_atomic.AddUint64(&mmGetSkill.afterGetSkillCounter, 1) + + if mmGetSkill.inspectFuncGetSkill != nil { + mmGetSkill.inspectFuncGetSkill(skillID) + } + + mm_params := FreshdeskInterfaceMockGetSkillParams{skillID} + + // Record call args + mmGetSkill.GetSkillMock.mutex.Lock() + mmGetSkill.GetSkillMock.callArgs = append(mmGetSkill.GetSkillMock.callArgs, &mm_params) + mmGetSkill.GetSkillMock.mutex.Unlock() + + for _, e := range mmGetSkill.GetSkillMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetSkill.GetSkillMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetSkill.GetSkillMock.defaultExpectation.Counter, 1) + mm_want := mmGetSkill.GetSkillMock.defaultExpectation.params + mm_want_ptrs := mmGetSkill.GetSkillMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetSkillParams{skillID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.skillID != nil && !minimock.Equal(*mm_want_ptrs.skillID, mm_got.skillID) { + mmGetSkill.t.Errorf("FreshdeskInterfaceMock.GetSkill got unexpected parameter skillID, want: %#v, got: %#v%s\n", *mm_want_ptrs.skillID, mm_got.skillID, minimock.Diff(*mm_want_ptrs.skillID, mm_got.skillID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetSkill.t.Errorf("FreshdeskInterfaceMock.GetSkill got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetSkill.GetSkillMock.defaultExpectation.results + if mm_results == nil { + mmGetSkill.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetSkill") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetSkill.funcGetSkill != nil { + return mmGetSkill.funcGetSkill(skillID) + } + mmGetSkill.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetSkill. %v", skillID) + return +} + +// GetSkillAfterCounter returns a count of finished FreshdeskInterfaceMock.GetSkill invocations +func (mmGetSkill *FreshdeskInterfaceMock) GetSkillAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetSkill.afterGetSkillCounter) +} + +// GetSkillBeforeCounter returns a count of FreshdeskInterfaceMock.GetSkill invocations +func (mmGetSkill *FreshdeskInterfaceMock) GetSkillBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetSkill.beforeGetSkillCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetSkill. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetSkill *mFreshdeskInterfaceMockGetSkill) Calls() []*FreshdeskInterfaceMockGetSkillParams { + mmGetSkill.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetSkillParams, len(mmGetSkill.callArgs)) + copy(argCopy, mmGetSkill.callArgs) + + mmGetSkill.mutex.RUnlock() + + return argCopy +} + +// MinimockGetSkillDone returns true if the count of the GetSkill invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetSkillDone() bool { + if m.GetSkillMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetSkillMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetSkillMock.invocationsDone() +} + +// MinimockGetSkillInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetSkillInspect() { + for _, e := range m.GetSkillMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetSkill with params: %#v", *e.params) + } + } + + afterGetSkillCounter := mm_atomic.LoadUint64(&m.afterGetSkillCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetSkillMock.defaultExpectation != nil && afterGetSkillCounter < 1 { + if m.GetSkillMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetSkill") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetSkill with params: %#v", *m.GetSkillMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetSkill != nil && afterGetSkillCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetSkill") + } + + if !m.GetSkillMock.invocationsDone() && afterGetSkillCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetSkill but found %d calls", + mm_atomic.LoadUint64(&m.GetSkillMock.expectedInvocations), afterGetSkillCounter) + } +} + +type mFreshdeskInterfaceMockGetTicket struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockGetTicketExpectation + expectations []*FreshdeskInterfaceMockGetTicketExpectation + + callArgs []*FreshdeskInterfaceMockGetTicketParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockGetTicketExpectation specifies expectation struct of the FreshdeskInterface.GetTicket +type FreshdeskInterfaceMockGetTicketExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockGetTicketParams + paramPtrs *FreshdeskInterfaceMockGetTicketParamPtrs + results *FreshdeskInterfaceMockGetTicketResults + Counter uint64 +} + +// FreshdeskInterfaceMockGetTicketParams contains parameters of the FreshdeskInterface.GetTicket +type FreshdeskInterfaceMockGetTicketParams struct { + ticketID int64 +} + +// FreshdeskInterfaceMockGetTicketParamPtrs contains pointers to parameters of the FreshdeskInterface.GetTicket +type FreshdeskInterfaceMockGetTicketParamPtrs struct { + ticketID *int64 +} + +// FreshdeskInterfaceMockGetTicketResults contains results of the FreshdeskInterface.GetTicket +type FreshdeskInterfaceMockGetTicketResults struct { + tp1 *TaskGetTicketResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Optional() *mFreshdeskInterfaceMockGetTicket { + mmGetTicket.optional = true + return mmGetTicket +} + +// Expect sets up expected params for FreshdeskInterface.GetTicket +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Expect(ticketID int64) *mFreshdeskInterfaceMockGetTicket { + if mmGetTicket.mock.funcGetTicket != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by Set") + } + + if mmGetTicket.defaultExpectation == nil { + mmGetTicket.defaultExpectation = &FreshdeskInterfaceMockGetTicketExpectation{} + } + + if mmGetTicket.defaultExpectation.paramPtrs != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by ExpectParams functions") + } + + mmGetTicket.defaultExpectation.params = &FreshdeskInterfaceMockGetTicketParams{ticketID} + for _, e := range mmGetTicket.expectations { + if minimock.Equal(e.params, mmGetTicket.defaultExpectation.params) { + mmGetTicket.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetTicket.defaultExpectation.params) + } + } + + return mmGetTicket +} + +// ExpectTicketIDParam1 sets up expected param ticketID for FreshdeskInterface.GetTicket +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) ExpectTicketIDParam1(ticketID int64) *mFreshdeskInterfaceMockGetTicket { + if mmGetTicket.mock.funcGetTicket != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by Set") + } + + if mmGetTicket.defaultExpectation == nil { + mmGetTicket.defaultExpectation = &FreshdeskInterfaceMockGetTicketExpectation{} + } + + if mmGetTicket.defaultExpectation.params != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by Expect") + } + + if mmGetTicket.defaultExpectation.paramPtrs == nil { + mmGetTicket.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockGetTicketParamPtrs{} + } + mmGetTicket.defaultExpectation.paramPtrs.ticketID = &ticketID + + return mmGetTicket +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.GetTicket +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Inspect(f func(ticketID int64)) *mFreshdeskInterfaceMockGetTicket { + if mmGetTicket.mock.inspectFuncGetTicket != nil { + mmGetTicket.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.GetTicket") + } + + mmGetTicket.mock.inspectFuncGetTicket = f + + return mmGetTicket +} + +// Return sets up results that will be returned by FreshdeskInterface.GetTicket +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Return(tp1 *TaskGetTicketResponse, err error) *FreshdeskInterfaceMock { + if mmGetTicket.mock.funcGetTicket != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by Set") + } + + if mmGetTicket.defaultExpectation == nil { + mmGetTicket.defaultExpectation = &FreshdeskInterfaceMockGetTicketExpectation{mock: mmGetTicket.mock} + } + mmGetTicket.defaultExpectation.results = &FreshdeskInterfaceMockGetTicketResults{tp1, err} + return mmGetTicket.mock +} + +// Set uses given function f to mock the FreshdeskInterface.GetTicket method +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Set(f func(ticketID int64) (tp1 *TaskGetTicketResponse, err error)) *FreshdeskInterfaceMock { + if mmGetTicket.defaultExpectation != nil { + mmGetTicket.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.GetTicket method") + } + + if len(mmGetTicket.expectations) > 0 { + mmGetTicket.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.GetTicket method") + } + + mmGetTicket.mock.funcGetTicket = f + return mmGetTicket.mock +} + +// When sets expectation for the FreshdeskInterface.GetTicket which will trigger the result defined by the following +// Then helper +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) When(ticketID int64) *FreshdeskInterfaceMockGetTicketExpectation { + if mmGetTicket.mock.funcGetTicket != nil { + mmGetTicket.mock.t.Fatalf("FreshdeskInterfaceMock.GetTicket mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockGetTicketExpectation{ + mock: mmGetTicket.mock, + params: &FreshdeskInterfaceMockGetTicketParams{ticketID}, + } + mmGetTicket.expectations = append(mmGetTicket.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.GetTicket return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockGetTicketExpectation) Then(tp1 *TaskGetTicketResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockGetTicketResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.GetTicket should be invoked +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Times(n uint64) *mFreshdeskInterfaceMockGetTicket { + if n == 0 { + mmGetTicket.mock.t.Fatalf("Times of FreshdeskInterfaceMock.GetTicket mock can not be zero") + } + mm_atomic.StoreUint64(&mmGetTicket.expectedInvocations, n) + return mmGetTicket +} + +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) invocationsDone() bool { + if len(mmGetTicket.expectations) == 0 && mmGetTicket.defaultExpectation == nil && mmGetTicket.mock.funcGetTicket == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmGetTicket.mock.afterGetTicketCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmGetTicket.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// GetTicket implements FreshdeskInterface +func (mmGetTicket *FreshdeskInterfaceMock) GetTicket(ticketID int64) (tp1 *TaskGetTicketResponse, err error) { + mm_atomic.AddUint64(&mmGetTicket.beforeGetTicketCounter, 1) + defer mm_atomic.AddUint64(&mmGetTicket.afterGetTicketCounter, 1) + + if mmGetTicket.inspectFuncGetTicket != nil { + mmGetTicket.inspectFuncGetTicket(ticketID) + } + + mm_params := FreshdeskInterfaceMockGetTicketParams{ticketID} + + // Record call args + mmGetTicket.GetTicketMock.mutex.Lock() + mmGetTicket.GetTicketMock.callArgs = append(mmGetTicket.GetTicketMock.callArgs, &mm_params) + mmGetTicket.GetTicketMock.mutex.Unlock() + + for _, e := range mmGetTicket.GetTicketMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmGetTicket.GetTicketMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmGetTicket.GetTicketMock.defaultExpectation.Counter, 1) + mm_want := mmGetTicket.GetTicketMock.defaultExpectation.params + mm_want_ptrs := mmGetTicket.GetTicketMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockGetTicketParams{ticketID} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ticketID != nil && !minimock.Equal(*mm_want_ptrs.ticketID, mm_got.ticketID) { + mmGetTicket.t.Errorf("FreshdeskInterfaceMock.GetTicket got unexpected parameter ticketID, want: %#v, got: %#v%s\n", *mm_want_ptrs.ticketID, mm_got.ticketID, minimock.Diff(*mm_want_ptrs.ticketID, mm_got.ticketID)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmGetTicket.t.Errorf("FreshdeskInterfaceMock.GetTicket got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmGetTicket.GetTicketMock.defaultExpectation.results + if mm_results == nil { + mmGetTicket.t.Fatal("No results are set for the FreshdeskInterfaceMock.GetTicket") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmGetTicket.funcGetTicket != nil { + return mmGetTicket.funcGetTicket(ticketID) + } + mmGetTicket.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.GetTicket. %v", ticketID) + return +} + +// GetTicketAfterCounter returns a count of finished FreshdeskInterfaceMock.GetTicket invocations +func (mmGetTicket *FreshdeskInterfaceMock) GetTicketAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetTicket.afterGetTicketCounter) +} + +// GetTicketBeforeCounter returns a count of FreshdeskInterfaceMock.GetTicket invocations +func (mmGetTicket *FreshdeskInterfaceMock) GetTicketBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmGetTicket.beforeGetTicketCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.GetTicket. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmGetTicket *mFreshdeskInterfaceMockGetTicket) Calls() []*FreshdeskInterfaceMockGetTicketParams { + mmGetTicket.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockGetTicketParams, len(mmGetTicket.callArgs)) + copy(argCopy, mmGetTicket.callArgs) + + mmGetTicket.mutex.RUnlock() + + return argCopy +} + +// MinimockGetTicketDone returns true if the count of the GetTicket invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockGetTicketDone() bool { + if m.GetTicketMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.GetTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.GetTicketMock.invocationsDone() +} + +// MinimockGetTicketInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockGetTicketInspect() { + for _, e := range m.GetTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetTicket with params: %#v", *e.params) + } + } + + afterGetTicketCounter := mm_atomic.LoadUint64(&m.afterGetTicketCounter) + // if default expectation was set then invocations count should be greater than zero + if m.GetTicketMock.defaultExpectation != nil && afterGetTicketCounter < 1 { + if m.GetTicketMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetTicket") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.GetTicket with params: %#v", *m.GetTicketMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcGetTicket != nil && afterGetTicketCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.GetTicket") + } + + if !m.GetTicketMock.invocationsDone() && afterGetTicketCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.GetTicket but found %d calls", + mm_atomic.LoadUint64(&m.GetTicketMock.expectedInvocations), afterGetTicketCounter) + } +} + +type mFreshdeskInterfaceMockReplyToTicket struct { + optional bool + mock *FreshdeskInterfaceMock + defaultExpectation *FreshdeskInterfaceMockReplyToTicketExpectation + expectations []*FreshdeskInterfaceMockReplyToTicketExpectation + + callArgs []*FreshdeskInterfaceMockReplyToTicketParams + mutex sync.RWMutex + + expectedInvocations uint64 +} + +// FreshdeskInterfaceMockReplyToTicketExpectation specifies expectation struct of the FreshdeskInterface.ReplyToTicket +type FreshdeskInterfaceMockReplyToTicketExpectation struct { + mock *FreshdeskInterfaceMock + params *FreshdeskInterfaceMockReplyToTicketParams + paramPtrs *FreshdeskInterfaceMockReplyToTicketParamPtrs + results *FreshdeskInterfaceMockReplyToTicketResults + Counter uint64 +} + +// FreshdeskInterfaceMockReplyToTicketParams contains parameters of the FreshdeskInterface.ReplyToTicket +type FreshdeskInterfaceMockReplyToTicketParams struct { + ticketID int64 + req *TaskReplyToTicketReq +} + +// FreshdeskInterfaceMockReplyToTicketParamPtrs contains pointers to parameters of the FreshdeskInterface.ReplyToTicket +type FreshdeskInterfaceMockReplyToTicketParamPtrs struct { + ticketID *int64 + req **TaskReplyToTicketReq +} + +// FreshdeskInterfaceMockReplyToTicketResults contains results of the FreshdeskInterface.ReplyToTicket +type FreshdeskInterfaceMockReplyToTicketResults struct { + tp1 *TaskReplyToTicketResponse + err error +} + +// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning +// the test will fail minimock's automatic final call check if the mocked method was not called at least once. +// Optional() makes method check to work in '0 or more' mode. +// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to +// catch the problems when the expected method call is totally skipped during test run. +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Optional() *mFreshdeskInterfaceMockReplyToTicket { + mmReplyToTicket.optional = true + return mmReplyToTicket +} + +// Expect sets up expected params for FreshdeskInterface.ReplyToTicket +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Expect(ticketID int64, req *TaskReplyToTicketReq) *mFreshdeskInterfaceMockReplyToTicket { + if mmReplyToTicket.mock.funcReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Set") + } + + if mmReplyToTicket.defaultExpectation == nil { + mmReplyToTicket.defaultExpectation = &FreshdeskInterfaceMockReplyToTicketExpectation{} + } + + if mmReplyToTicket.defaultExpectation.paramPtrs != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by ExpectParams functions") + } + + mmReplyToTicket.defaultExpectation.params = &FreshdeskInterfaceMockReplyToTicketParams{ticketID, req} + for _, e := range mmReplyToTicket.expectations { + if minimock.Equal(e.params, mmReplyToTicket.defaultExpectation.params) { + mmReplyToTicket.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmReplyToTicket.defaultExpectation.params) + } + } + + return mmReplyToTicket +} + +// ExpectTicketIDParam1 sets up expected param ticketID for FreshdeskInterface.ReplyToTicket +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) ExpectTicketIDParam1(ticketID int64) *mFreshdeskInterfaceMockReplyToTicket { + if mmReplyToTicket.mock.funcReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Set") + } + + if mmReplyToTicket.defaultExpectation == nil { + mmReplyToTicket.defaultExpectation = &FreshdeskInterfaceMockReplyToTicketExpectation{} + } + + if mmReplyToTicket.defaultExpectation.params != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Expect") + } + + if mmReplyToTicket.defaultExpectation.paramPtrs == nil { + mmReplyToTicket.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockReplyToTicketParamPtrs{} + } + mmReplyToTicket.defaultExpectation.paramPtrs.ticketID = &ticketID + + return mmReplyToTicket +} + +// ExpectReqParam2 sets up expected param req for FreshdeskInterface.ReplyToTicket +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) ExpectReqParam2(req *TaskReplyToTicketReq) *mFreshdeskInterfaceMockReplyToTicket { + if mmReplyToTicket.mock.funcReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Set") + } + + if mmReplyToTicket.defaultExpectation == nil { + mmReplyToTicket.defaultExpectation = &FreshdeskInterfaceMockReplyToTicketExpectation{} + } + + if mmReplyToTicket.defaultExpectation.params != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Expect") + } + + if mmReplyToTicket.defaultExpectation.paramPtrs == nil { + mmReplyToTicket.defaultExpectation.paramPtrs = &FreshdeskInterfaceMockReplyToTicketParamPtrs{} + } + mmReplyToTicket.defaultExpectation.paramPtrs.req = &req + + return mmReplyToTicket +} + +// Inspect accepts an inspector function that has same arguments as the FreshdeskInterface.ReplyToTicket +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Inspect(f func(ticketID int64, req *TaskReplyToTicketReq)) *mFreshdeskInterfaceMockReplyToTicket { + if mmReplyToTicket.mock.inspectFuncReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("Inspect function is already set for FreshdeskInterfaceMock.ReplyToTicket") + } + + mmReplyToTicket.mock.inspectFuncReplyToTicket = f + + return mmReplyToTicket +} + +// Return sets up results that will be returned by FreshdeskInterface.ReplyToTicket +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Return(tp1 *TaskReplyToTicketResponse, err error) *FreshdeskInterfaceMock { + if mmReplyToTicket.mock.funcReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Set") + } + + if mmReplyToTicket.defaultExpectation == nil { + mmReplyToTicket.defaultExpectation = &FreshdeskInterfaceMockReplyToTicketExpectation{mock: mmReplyToTicket.mock} + } + mmReplyToTicket.defaultExpectation.results = &FreshdeskInterfaceMockReplyToTicketResults{tp1, err} + return mmReplyToTicket.mock +} + +// Set uses given function f to mock the FreshdeskInterface.ReplyToTicket method +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Set(f func(ticketID int64, req *TaskReplyToTicketReq) (tp1 *TaskReplyToTicketResponse, err error)) *FreshdeskInterfaceMock { + if mmReplyToTicket.defaultExpectation != nil { + mmReplyToTicket.mock.t.Fatalf("Default expectation is already set for the FreshdeskInterface.ReplyToTicket method") + } + + if len(mmReplyToTicket.expectations) > 0 { + mmReplyToTicket.mock.t.Fatalf("Some expectations are already set for the FreshdeskInterface.ReplyToTicket method") + } + + mmReplyToTicket.mock.funcReplyToTicket = f + return mmReplyToTicket.mock +} + +// When sets expectation for the FreshdeskInterface.ReplyToTicket which will trigger the result defined by the following +// Then helper +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) When(ticketID int64, req *TaskReplyToTicketReq) *FreshdeskInterfaceMockReplyToTicketExpectation { + if mmReplyToTicket.mock.funcReplyToTicket != nil { + mmReplyToTicket.mock.t.Fatalf("FreshdeskInterfaceMock.ReplyToTicket mock is already set by Set") + } + + expectation := &FreshdeskInterfaceMockReplyToTicketExpectation{ + mock: mmReplyToTicket.mock, + params: &FreshdeskInterfaceMockReplyToTicketParams{ticketID, req}, + } + mmReplyToTicket.expectations = append(mmReplyToTicket.expectations, expectation) + return expectation +} + +// Then sets up FreshdeskInterface.ReplyToTicket return parameters for the expectation previously defined by the When method +func (e *FreshdeskInterfaceMockReplyToTicketExpectation) Then(tp1 *TaskReplyToTicketResponse, err error) *FreshdeskInterfaceMock { + e.results = &FreshdeskInterfaceMockReplyToTicketResults{tp1, err} + return e.mock +} + +// Times sets number of times FreshdeskInterface.ReplyToTicket should be invoked +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Times(n uint64) *mFreshdeskInterfaceMockReplyToTicket { + if n == 0 { + mmReplyToTicket.mock.t.Fatalf("Times of FreshdeskInterfaceMock.ReplyToTicket mock can not be zero") + } + mm_atomic.StoreUint64(&mmReplyToTicket.expectedInvocations, n) + return mmReplyToTicket +} + +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) invocationsDone() bool { + if len(mmReplyToTicket.expectations) == 0 && mmReplyToTicket.defaultExpectation == nil && mmReplyToTicket.mock.funcReplyToTicket == nil { + return true + } + + totalInvocations := mm_atomic.LoadUint64(&mmReplyToTicket.mock.afterReplyToTicketCounter) + expectedInvocations := mm_atomic.LoadUint64(&mmReplyToTicket.expectedInvocations) + + return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations) +} + +// ReplyToTicket implements FreshdeskInterface +func (mmReplyToTicket *FreshdeskInterfaceMock) ReplyToTicket(ticketID int64, req *TaskReplyToTicketReq) (tp1 *TaskReplyToTicketResponse, err error) { + mm_atomic.AddUint64(&mmReplyToTicket.beforeReplyToTicketCounter, 1) + defer mm_atomic.AddUint64(&mmReplyToTicket.afterReplyToTicketCounter, 1) + + if mmReplyToTicket.inspectFuncReplyToTicket != nil { + mmReplyToTicket.inspectFuncReplyToTicket(ticketID, req) + } + + mm_params := FreshdeskInterfaceMockReplyToTicketParams{ticketID, req} + + // Record call args + mmReplyToTicket.ReplyToTicketMock.mutex.Lock() + mmReplyToTicket.ReplyToTicketMock.callArgs = append(mmReplyToTicket.ReplyToTicketMock.callArgs, &mm_params) + mmReplyToTicket.ReplyToTicketMock.mutex.Unlock() + + for _, e := range mmReplyToTicket.ReplyToTicketMock.expectations { + if minimock.Equal(*e.params, mm_params) { + mm_atomic.AddUint64(&e.Counter, 1) + return e.results.tp1, e.results.err + } + } + + if mmReplyToTicket.ReplyToTicketMock.defaultExpectation != nil { + mm_atomic.AddUint64(&mmReplyToTicket.ReplyToTicketMock.defaultExpectation.Counter, 1) + mm_want := mmReplyToTicket.ReplyToTicketMock.defaultExpectation.params + mm_want_ptrs := mmReplyToTicket.ReplyToTicketMock.defaultExpectation.paramPtrs + + mm_got := FreshdeskInterfaceMockReplyToTicketParams{ticketID, req} + + if mm_want_ptrs != nil { + + if mm_want_ptrs.ticketID != nil && !minimock.Equal(*mm_want_ptrs.ticketID, mm_got.ticketID) { + mmReplyToTicket.t.Errorf("FreshdeskInterfaceMock.ReplyToTicket got unexpected parameter ticketID, want: %#v, got: %#v%s\n", *mm_want_ptrs.ticketID, mm_got.ticketID, minimock.Diff(*mm_want_ptrs.ticketID, mm_got.ticketID)) + } + + if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) { + mmReplyToTicket.t.Errorf("FreshdeskInterfaceMock.ReplyToTicket got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req)) + } + + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + mmReplyToTicket.t.Errorf("FreshdeskInterfaceMock.ReplyToTicket got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) + } + + mm_results := mmReplyToTicket.ReplyToTicketMock.defaultExpectation.results + if mm_results == nil { + mmReplyToTicket.t.Fatal("No results are set for the FreshdeskInterfaceMock.ReplyToTicket") + } + return (*mm_results).tp1, (*mm_results).err + } + if mmReplyToTicket.funcReplyToTicket != nil { + return mmReplyToTicket.funcReplyToTicket(ticketID, req) + } + mmReplyToTicket.t.Fatalf("Unexpected call to FreshdeskInterfaceMock.ReplyToTicket. %v %v", ticketID, req) + return +} + +// ReplyToTicketAfterCounter returns a count of finished FreshdeskInterfaceMock.ReplyToTicket invocations +func (mmReplyToTicket *FreshdeskInterfaceMock) ReplyToTicketAfterCounter() uint64 { + return mm_atomic.LoadUint64(&mmReplyToTicket.afterReplyToTicketCounter) +} + +// ReplyToTicketBeforeCounter returns a count of FreshdeskInterfaceMock.ReplyToTicket invocations +func (mmReplyToTicket *FreshdeskInterfaceMock) ReplyToTicketBeforeCounter() uint64 { + return mm_atomic.LoadUint64(&mmReplyToTicket.beforeReplyToTicketCounter) +} + +// Calls returns a list of arguments used in each call to FreshdeskInterfaceMock.ReplyToTicket. +// The list is in the same order as the calls were made (i.e. recent calls have a higher index) +func (mmReplyToTicket *mFreshdeskInterfaceMockReplyToTicket) Calls() []*FreshdeskInterfaceMockReplyToTicketParams { + mmReplyToTicket.mutex.RLock() + + argCopy := make([]*FreshdeskInterfaceMockReplyToTicketParams, len(mmReplyToTicket.callArgs)) + copy(argCopy, mmReplyToTicket.callArgs) + + mmReplyToTicket.mutex.RUnlock() + + return argCopy +} + +// MinimockReplyToTicketDone returns true if the count of the ReplyToTicket invocations corresponds +// the number of defined expectations +func (m *FreshdeskInterfaceMock) MinimockReplyToTicketDone() bool { + if m.ReplyToTicketMock.optional { + // Optional methods provide '0 or more' call count restriction. + return true + } + + for _, e := range m.ReplyToTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + return false + } + } + + return m.ReplyToTicketMock.invocationsDone() +} + +// MinimockReplyToTicketInspect logs each unmet expectation +func (m *FreshdeskInterfaceMock) MinimockReplyToTicketInspect() { + for _, e := range m.ReplyToTicketMock.expectations { + if mm_atomic.LoadUint64(&e.Counter) < 1 { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.ReplyToTicket with params: %#v", *e.params) + } + } + + afterReplyToTicketCounter := mm_atomic.LoadUint64(&m.afterReplyToTicketCounter) + // if default expectation was set then invocations count should be greater than zero + if m.ReplyToTicketMock.defaultExpectation != nil && afterReplyToTicketCounter < 1 { + if m.ReplyToTicketMock.defaultExpectation.params == nil { + m.t.Error("Expected call to FreshdeskInterfaceMock.ReplyToTicket") + } else { + m.t.Errorf("Expected call to FreshdeskInterfaceMock.ReplyToTicket with params: %#v", *m.ReplyToTicketMock.defaultExpectation.params) + } + } + // if func was set then invocations count should be greater than zero + if m.funcReplyToTicket != nil && afterReplyToTicketCounter < 1 { + m.t.Error("Expected call to FreshdeskInterfaceMock.ReplyToTicket") + } + + if !m.ReplyToTicketMock.invocationsDone() && afterReplyToTicketCounter > 0 { + m.t.Errorf("Expected %d calls to FreshdeskInterfaceMock.ReplyToTicket but found %d calls", + mm_atomic.LoadUint64(&m.ReplyToTicketMock.expectedInvocations), afterReplyToTicketCounter) + } +} + +// MinimockFinish checks that all mocked methods have been called the expected number of times +func (m *FreshdeskInterfaceMock) MinimockFinish() { + m.finishOnce.Do(func() { + if !m.minimockDone() { + m.MinimockCreateCompanyInspect() + + m.MinimockCreateContactInspect() + + m.MinimockCreateTicketInspect() + + m.MinimockCreateTicketNoteInspect() + + m.MinimockGetAgentInspect() + + m.MinimockGetAllInspect() + + m.MinimockGetAllConversationsInspect() + + m.MinimockGetCompanyInspect() + + m.MinimockGetContactInspect() + + m.MinimockGetGroupInspect() + + m.MinimockGetProductInspect() + + m.MinimockGetRoleInspect() + + m.MinimockGetSkillInspect() + + m.MinimockGetTicketInspect() + + m.MinimockReplyToTicketInspect() + } + }) +} + +// MinimockWait waits for all mocked methods to be called the expected number of times +func (m *FreshdeskInterfaceMock) MinimockWait(timeout mm_time.Duration) { + timeoutCh := mm_time.After(timeout) + for { + if m.minimockDone() { + return + } + select { + case <-timeoutCh: + m.MinimockFinish() + return + case <-mm_time.After(10 * mm_time.Millisecond): + } + } +} + +func (m *FreshdeskInterfaceMock) minimockDone() bool { + done := true + return done && + m.MinimockCreateCompanyDone() && + m.MinimockCreateContactDone() && + m.MinimockCreateTicketDone() && + m.MinimockCreateTicketNoteDone() && + m.MinimockGetAgentDone() && + m.MinimockGetAllDone() && + m.MinimockGetAllConversationsDone() && + m.MinimockGetCompanyDone() && + m.MinimockGetContactDone() && + m.MinimockGetGroupDone() && + m.MinimockGetProductDone() && + m.MinimockGetRoleDone() && + m.MinimockGetSkillDone() && + m.MinimockGetTicketDone() && + m.MinimockReplyToTicketDone() +} diff --git a/application/freshdesk/v0/get_all.go b/application/freshdesk/v0/get_all.go new file mode 100644 index 00000000..db8ec284 --- /dev/null +++ b/application/freshdesk/v0/get_all.go @@ -0,0 +1,125 @@ +package freshdesk + +import ( + "fmt" + "strings" + + "github.com/go-resty/resty/v2" + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +func (c *FreshdeskClient) GetAll(objectType string, pagination bool, paginationPath string) ([]TaskGetAllResponse, string, error) { + + resp := []TaskGetAllResponse{} + + httpReq := c.httpclient.R().SetResult(&resp) + + var rawResp *resty.Response + var err error + if !pagination { + + var path string + if objectType != "Skills" { + path = strings.ToLower(objectType) + } else { + path = "admin/skills" + } + + rawResp, err = httpReq.Get(fmt.Sprintf("/%s", path)) + + } else { + rawResp, err = httpReq.Get(paginationPath) + } + + if err != nil { + return nil, "", err + } + + // Will exist if there is a next page + linkHeader := rawResp.Header().Get("Link") + + var nextPage string + if linkHeader != "" { + startIndex := strings.Index(linkHeader, "<") + endIndex := strings.Index(linkHeader, ">") + nextPage = linkHeader[startIndex+1 : endIndex] + + return resp, nextPage, nil + } + + return resp, "", nil +} + +// Task 1: Get All +type TaskGetAllInput struct { + ObjectType string `json:"object-type"` + Length int `json:"length"` +} + +type TaskGetAllResponse struct { + ID int64 `json:"id"` +} + +type TaskGetAllOutput struct { + IDs []int64 `json:"ids"` + IDLength int `json:"id-length"` +} + +func (e *execution) TaskGetAll(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetAllInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + if inputStruct.Length < 0 || inputStruct.Length > 500 { + return nil, fmt.Errorf("please set the limit between 0 and 500") + } + + resp, paginationPath, err := e.client.GetAll(inputStruct.ObjectType, false, "") + + if err != nil { + return nil, err + } + + counter := 0 + outputStruct := TaskGetAllOutput{} + for _, value := range resp { + outputStruct.IDs = append(outputStruct.IDs, value.ID) + counter += 1 + if counter == inputStruct.Length { + break + } + } + + if counter < inputStruct.Length { + for paginationPath != "" && counter < inputStruct.Length { + respPage, nextPage, err := e.client.GetAll(inputStruct.ObjectType, true, paginationPath) + + if err != nil { + return nil, err + } + + for _, value := range respPage { + outputStruct.IDs = append(outputStruct.IDs, value.ID) + counter += 1 + if counter == inputStruct.Length { + break + } + } + paginationPath = nextPage + } + } + + outputStruct.IDLength = len(outputStruct.IDs) + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} diff --git a/application/freshdesk/v0/get_all_test.go b/application/freshdesk/v0/get_all_test.go new file mode 100644 index 00000000..8a632af8 --- /dev/null +++ b/application/freshdesk/v0/get_all_test.go @@ -0,0 +1,90 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +func TestComponent_ExecuteGetAllTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetAllMock. + When("Tickets", false, ""). + Then([]TaskGetAllResponse{ + {ID: 1}, + {ID: 2}, + {ID: 3}, + {ID: 4}, + {ID: 5}, + }, "https://yourdomain.freshdesk.com/api/v2/tickets?page=2", nil) + + FreshdeskClientMock.GetAllMock. + When("Tickets", true, "https://yourdomain.freshdesk.com/api/v2/tickets?page=2"). + Then([]TaskGetAllResponse{ + {ID: 6}, + {ID: 7}, + }, "", nil) + + tc := struct { + name string + input TaskGetAllInput + wantOutput TaskGetAllOutput + }{ + name: "ok - task get all", + input: TaskGetAllInput{ + ObjectType: "Tickets", + Length: 7, + }, + wantOutput: TaskGetAllOutput{ + IDs: []int64{1, 2, 3, 4, 5, 6, 7}, + IDLength: 7, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetAll}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetAll + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/application/freshdesk/v0/main.go b/application/freshdesk/v0/main.go new file mode 100644 index 00000000..720f985a --- /dev/null +++ b/application/freshdesk/v0/main.go @@ -0,0 +1,327 @@ +//go:generate compogen readme ./config ./README.mdx + +package freshdesk + +import ( + "context" + "fmt" + "strings" + "sync" + + _ "embed" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/instill-ai/component/base" +) + +const ( + version = "v2" + + taskGetTicket = "TASK_GET_TICKET" + taskCreateTicket = "TASK_CREATE_TICKET" + taskReplyToTicket = "TASK_REPLY_TO_TICKET" + taskCreateTicketNote = "TASK_CREATE_TICKET_NOTE" + taskGetContact = "TASK_GET_CONTACT" + taskCreateContact = "TASK_CREATE_CONTACT" + taskGetCompany = "TASK_GET_COMPANY" + taskCreateCompany = "TASK_CREATE_COMPANY" + taskGetAll = "TASK_GET_ALL" + taskGetAllConversations = "TASK_GET_ALL_CONVERSATIONS" + taskGetProduct = "TASK_GET_PRODUCT" + taskGetAgent = "TASK_GET_AGENT" + taskGetRole = "TASK_GET_ROLE" + taskGetGroup = "TASK_GET_GROUP" + taskGetSkill = "TASK_GET_SKILL" +) + +var ( + //go:embed config/definition.json + definitionJSON []byte + //go:embed config/tasks.json + tasksJSON []byte + //go:embed config/setup.json + setupJSON []byte + + once sync.Once + comp *component +) + +type component struct { + base.Component +} + +type execution struct { + base.ComponentExecution + client FreshdeskInterface + execute func(*structpb.Struct) (*structpb.Struct, error) +} + +// Init returns an implementation of IComponent that implements the greeting +// task. +func Init(bc base.Component) *component { + once.Do(func() { + comp = &component{Component: bc} + err := comp.LoadDefinition(definitionJSON, setupJSON, tasksJSON, nil) + if err != nil { + panic(err) + } + }) + return comp +} + +func (c *component) CreateExecution(x base.ComponentExecution) (base.IExecution, error) { + e := &execution{ + ComponentExecution: x, + client: newClient(x.Setup, c.GetLogger()), + } + + switch x.Task { + case taskGetTicket: + e.execute = e.TaskGetTicket + case taskCreateTicket: + e.execute = e.TaskCreateTicket + case taskReplyToTicket: + e.execute = e.TaskReplyToTicket + case taskCreateTicketNote: + e.execute = e.TaskCreateTicketNote + case taskGetAllConversations: + e.execute = e.TaskGetAllConversations + case taskGetContact: + e.execute = e.TaskGetContact + case taskCreateContact: + e.execute = e.TaskCreateContact + case taskGetCompany: + e.execute = e.TaskGetCompany + case taskCreateCompany: + e.execute = e.TaskCreateCompany + case taskGetAll: + e.execute = e.TaskGetAll + case taskGetProduct: + e.execute = e.TaskGetProduct + case taskGetAgent: + e.execute = e.TaskGetAgent + case taskGetRole: + e.execute = e.TaskGetRole + case taskGetGroup: + e.execute = e.TaskGetGroup + case taskGetSkill: + e.execute = e.TaskGetSkill + default: + return nil, fmt.Errorf("unsupported task") + } + + return e, nil +} + +func (e *execution) Execute(ctx context.Context, jobs []*base.Job) error { + return base.SequentialExecutor(ctx, jobs, e.execute) +} + +func convertTimestampResp(timestamp string) string { + // freshdesk response timestamp is always in the format of YYYY-MM-DDTHH:MM:SSZ and in UTC. + // this function will convert it to YYYY-MM-DD HH:MM:SS UTC + + if timestamp == "" { + return timestamp + } + formattedTime := strings.Replace(timestamp, "T", " ", 1) + formattedTime = strings.Replace(formattedTime, "Z", " ", 1) + formattedTime += "UTC" + + return formattedTime +} + +func checkForNilString(input *[]string) *[]string { + if *input == nil { + return &[]string{} + } + return input +} + +func convertLanguageToCode(language string) string { + + switch language { + case "Arabic": + return "ar" + case "Bosnian": + return "bs" + case "Bulgarian": + return "bg" + case "Catalan": + return "ca" + case "Chinese": + return "zh-CN" + case "Chinese (Traditional)": + return "zh-TW" + case "Croatian": + return "hr" + case "Czech": + return "cs" + case "Danish": + return "da" + case "Dutch": + return "nl" + case "English": + return "en" + case "Estonian": + return "et" + case "Filipino": + return "fil" + case "Finnish": + return "fi" + case "French": + return "fr" + case "German": + return "de" + case "Greek": + return "el" + case "Hebrew": + return "he" + case "Hungarian": + return "hu" + case "Icelandic": + return "is" + case "Indonesian": + return "id" + case "Italian": + return "it" + case "Japanese": + return "ja-JP" + case "Korean": + return "ko" + case "Latvian": + return "lv-LV" + case "Lithuanian": + return "lt" + case "Malay": + return "ms" + case "Norwegian": + return "nb-NO" + case "Polish": + return "pl" + case "Portuguese (BR)": + return "pt-BR" + case "Portuguese/Portugal": + return "pt-PT" + case "Romanian": + return "ro" + case "Russian": + return "ru-RU" + case "Serbian": + return "sr" + case "Slovak": + return "sk" + case "Slovenian": + return "sl" + case "Spanish": + return "es" + case "Spanish (Latin America)": + return "es-LA" + case "Swedish": + return "sv-SE" + case "Thai": + return "th" + case "Turkish": + return "tr" + case "Ukrainian": + return "uk" + case "Vietnamese": + return "vi" + default: + return "" + } +} + +func convertCodeToLanguage(code string) string { + switch code { + case "en": + return "English" + case "ar": + return "Arabic" + case "bs": + return "Bosnian" + case "bg": + return "Bulgarian" + case "ca": + return "Catalan" + case "zh-CN": + return "Chinese" + case "zh-TW": + return "Chinese (Traditional)" + case "hr": + return "Croatian" + case "cs": + return "Czech" + case "da": + return "Danish" + case "nl": + return "Dutch" + case "et": + return "Estonian" + case "fil": + return "Filipino" + case "fi": + return "Finnish" + case "fr": + return "French" + case "de": + return "German" + case "el": + return "Greek" + case "he": + return "Hebrew" + case "hu": + return "Hungarian" + case "is": + return "Icelandic" + case "id": + return "Indonesian" + case "it": + return "Italian" + case "ja-JP": + return "Japanese" + case "ko": + return "Korean" + case "lv-LV": + return "Latvian" + case "lt": + return "Lithuanian" + case "ms": + return "Malay" + case "nb-NO": + return "Norwegian" + case "pl": + return "Polish" + case "pt-BR": + return "Portuguese (BR)" + case "pt-PT": + return "Portuguese/Portugal" + case "ro": + return "Romanian" + case "ru-RU": + return "Russian" + case "sr": + return "Serbian" + case "sk": + return "Slovak" + case "sl": + return "Slovenian" + case "es": + return "Spanish" + case "es-LA": + return "Spanish (Latin America)" + case "sv-SE": + return "Swedish" + case "th": + return "Thai" + case "tr": + return "Turkish" + case "uk": + return "Ukrainian" + case "vi": + return "Vietnamese" + default: + return code + } +} diff --git a/application/freshdesk/v0/product.go b/application/freshdesk/v0/product.go new file mode 100644 index 00000000..3db143ed --- /dev/null +++ b/application/freshdesk/v0/product.go @@ -0,0 +1,81 @@ +package freshdesk + +import ( + "fmt" + + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +const ( + ProductPath = "products" +) + +// API function for Product + +func (c *FreshdeskClient) GetProduct(productID int64) (*TaskGetProductResponse, error) { + resp := &TaskGetProductResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", ProductPath, productID)); err != nil { + return nil, err + } + return resp, nil +} + +// Task 1: Get Product + +type TaskGetProductInput struct { + ProductID int64 `json:"product-id"` +} + +type TaskGetProductResponse struct { + Name string `json:"name"` + Description string `json:"description"` + PrimaryEmail string `json:"primary_email"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + Default bool `json:"default"` +} + +type TaskGetProductOutput struct { + Name string `json:"name"` + Description string `json:"description"` + PrimaryEmail string `json:"primary-email"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` + Default bool `json:"default"` +} + +func (e *execution) TaskGetProduct(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetProductInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetProduct(inputStruct.ProductID) + + if err != nil { + return nil, err + } + + outputStruct := TaskGetProductOutput{ + Name: resp.Name, + Description: resp.Description, + PrimaryEmail: resp.PrimaryEmail, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + Default: resp.Default, + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil + +} diff --git a/application/freshdesk/v0/product_test.go b/application/freshdesk/v0/product_test.go new file mode 100644 index 00000000..6a652983 --- /dev/null +++ b/application/freshdesk/v0/product_test.go @@ -0,0 +1,88 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +func TestComponent_ExecuteGetProductTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetProductMock. + When(154000129735). + Then( + &TaskGetProductResponse{ + Name: "Fake Product", + Description: "This is a fake product", + PrimaryEmail: "randomemail@gmail.com", + CreatedAt: "2024-08-29T09:35:16Z", + UpdatedAt: "2024-08-29T09:35:16Z", + Default: true, + }, nil) + + tc := struct { + name string + input TaskGetProductInput + wantOutput TaskGetProductOutput + }{ + name: "ok - task get product", + input: TaskGetProductInput{ + ProductID: 154000129735, + }, + wantOutput: TaskGetProductOutput{ + Name: "Fake Product", + Description: "This is a fake product", + PrimaryEmail: "randomemail@gmail.com", + CreatedAt: "2024-08-29 09:35:16 UTC", + UpdatedAt: "2024-08-29 09:35:16 UTC", + Default: true, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetProduct}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetProduct + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/application/freshdesk/v0/ticket.go b/application/freshdesk/v0/ticket.go new file mode 100644 index 00000000..e9320020 --- /dev/null +++ b/application/freshdesk/v0/ticket.go @@ -0,0 +1,710 @@ +package freshdesk + +import ( + "fmt" + "strings" + + "github.com/go-resty/resty/v2" + "github.com/instill-ai/component/base" + "google.golang.org/protobuf/types/known/structpb" +) + +const ( + TicketPath = "tickets" +) + +// API functions for Ticket + +func (c *FreshdeskClient) GetTicket(ticketID int64) (*TaskGetTicketResponse, error) { + + resp := &TaskGetTicketResponse{} + + httpReq := c.httpclient.R().SetResult(resp) + if _, err := httpReq.Get(fmt.Sprintf("/%s/%d", TicketPath, ticketID)); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) CreateTicket(req *TaskCreateTicketReq) (*TaskCreateTicketResponse, error) { + resp := &TaskCreateTicketResponse{} + httpReq := c.httpclient.R().SetBody(req).SetResult(resp) + if _, err := httpReq.Post("/" + TicketPath); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) ReplyToTicket(ticketID int64, req *TaskReplyToTicketReq) (*TaskReplyToTicketResponse, error) { + resp := &TaskReplyToTicketResponse{} + httpReq := c.httpclient.R().SetBody(req).SetResult(resp) + if _, err := httpReq.Post(fmt.Sprintf("/%s/%d/reply", TicketPath, ticketID)); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) CreateTicketNote(ticketID int64, req *TaskCreateTicketNoteReq) (*TaskCreateTicketNoteResponse, error) { + resp := &TaskCreateTicketNoteResponse{} + httpReq := c.httpclient.R().SetBody(req).SetResult(resp) + if _, err := httpReq.Post(fmt.Sprintf("/%s/%d/notes", TicketPath, ticketID)); err != nil { + return nil, err + } + return resp, nil +} + +func (c *FreshdeskClient) GetAllConversations(ticketID int64, pagination bool, paginationPath string) ([]TaskGetAllConversationsResponse, string, error) { + resp := []TaskGetAllConversationsResponse{} + + httpReq := c.httpclient.R().SetResult(&resp) + + var rawResp *resty.Response + var err error + if !pagination { + rawResp, err = httpReq.Get(fmt.Sprintf("/%s/%d/conversations", TicketPath, ticketID)) + + } else { + rawResp, err = httpReq.Get(paginationPath) + } + + if err != nil { + return nil, "", err + } + + // Will exist if there is a next page + linkHeader := rawResp.Header().Get("Link") + + var nextPage string + if linkHeader != "" { + startIndex := strings.Index(linkHeader, "<") + endIndex := strings.Index(linkHeader, ">") + nextPage = linkHeader[startIndex+1 : endIndex] + + return resp, nextPage, nil + } + + return resp, "", nil +} + +//Task 1: Get Ticket + +type TaskGetTicketInput struct { + TicketID int64 `json:"ticket-id"` +} + +type TaskGetTicketResponse struct { + Subject string `json:"subject"` + DescriptionText string `json:"description_text"` + Source int `json:"source"` + Status int `json:"status"` + Priority int `json:"priority"` + TicketType string `json:"type"` + AssociationType int `json:"association_type"` + AssociatedTicketList []int `json:"associated_tickets_list"` + Tags []string `json:"tags"` + CCEmails []string `json:"cc_emails"` + ForwardEmails []string `json:"fwd_emails"` + ReplyCCEmails []string `json:"reply_cc_emails"` + RequesterID int64 `json:"requester_id"` + ResponderID int64 `json:"responder_id"` + CompanyID int64 `json:"company_id"` + GroupID int64 `json:"group_id"` + ProductID int64 `json:"product_id"` + SupportEmail string `json:"support_email"` + ToEmails []string `json:"to_emails"` + Spam bool `json:"spam"` + IsEscalated bool `json:"is_escalated"` + DueBy string `json:"due_by"` + FirstResponseDueBy string `json:"fr_due_by"` + FirstResponseEscalated bool `json:"fr_escalated"` + NextResponseDueBy string `json:"nr_due_by"` + NextResponseEscalated bool `json:"nr_escalated"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + Attachments []taskGetTicketOutputAttachment `json:"attachments"` + SentimentScore int `json:"sentiment_score"` + InitialSentimentScore int `json:"initial_sentiment_score"` + CustomFields map[string]interface{} `json:"custom_fields"` +} + +type TaskGetTicketOutput struct { + Subject string `json:"subject"` + DescriptionText string `json:"description-text"` + Source string `json:"source"` + Status string `json:"status"` + Priority string `json:"priority"` + TicketType string `json:"ticket-type,omitempty"` + AssociationType string `json:"association-type"` + AssociatedTicketList []int `json:"associated-ticket-list,omitempty"` + Tags []string `json:"tags"` + CCEmails []string `json:"cc-emails"` + ForwardEmails []string `json:"forward-emails"` + ReplyCCEmails []string `json:"reply-cc-emails"` + RequesterID int64 `json:"requester-id"` + ResponderID int64 `json:"responder-id,omitempty"` + CompanyID int64 `json:"company-id,omitempty"` + GroupID int64 `json:"group-id,omitempty"` + ProductID int64 `json:"product-id,omitempty"` + SupportEmail string `json:"support-email,omitempty"` + ToEmails []string `json:"to-emails"` + Spam bool `json:"spam"` + DueBy string `json:"due-by,omitempty"` + IsEscalated bool `json:"is-escalated"` + FirstResponseDueBy string `json:"first-response-due-by,omitempty"` + FirstResponseEscalated bool `json:"first-response-escalated"` + NextResponseDueBy string `json:"next-response-due-by,omitempty"` + NextResponseEscalated bool `json:"next-response-escalated"` + CreatedAt string `json:"created-at"` + UpdatedAt string `json:"updated-at"` + Attachments []taskGetTicketOutputAttachment `json:"attachments,omitempty"` + SentimentScore int `json:"sentiment-score"` + InitialSentimentScore int `json:"initial-sentiment-score"` + CustomFields map[string]interface{} `json:"custom-fields,omitempty"` +} + +type taskGetTicketOutputAttachment struct { + Name string `json:"name"` + ContentType string `json:"content-type"` + URL string `json:"url"` +} + +func (e *execution) TaskGetTicket(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetTicketInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + resp, err := e.client.GetTicket(inputStruct.TicketID) + if err != nil { + return nil, err + } + + outputStruct := TaskGetTicketOutput{ + Subject: resp.Subject, + DescriptionText: resp.DescriptionText, + Source: convertSourceToString(resp.Source), + Status: convertStatusToString(resp.Status), + Priority: convertPriorityToString(resp.Priority), + TicketType: resp.TicketType, + AssociationType: convertAssociationType(resp.AssociationType), + AssociatedTicketList: resp.AssociatedTicketList, + Tags: *checkForNilString(&resp.Tags), + CCEmails: *checkForNilString(&resp.CCEmails), + ForwardEmails: *checkForNilString(&resp.ForwardEmails), + ReplyCCEmails: *checkForNilString(&resp.ReplyCCEmails), + RequesterID: resp.RequesterID, + ResponderID: resp.ResponderID, + CompanyID: resp.CompanyID, + GroupID: resp.GroupID, + ProductID: resp.ProductID, + SupportEmail: resp.SupportEmail, + ToEmails: *checkForNilString(&resp.ToEmails), + Spam: resp.Spam, + DueBy: convertTimestampResp(resp.DueBy), + IsEscalated: resp.IsEscalated, + FirstResponseDueBy: convertTimestampResp(resp.FirstResponseDueBy), + FirstResponseEscalated: resp.FirstResponseEscalated, + NextResponseDueBy: convertTimestampResp(resp.NextResponseDueBy), + NextResponseEscalated: resp.NextResponseEscalated, + CreatedAt: convertTimestampResp(resp.CreatedAt), + UpdatedAt: convertTimestampResp(resp.UpdatedAt), + Attachments: resp.Attachments, + SentimentScore: resp.SentimentScore, + InitialSentimentScore: resp.InitialSentimentScore, + } + + if len(resp.CustomFields) > 0 { + outputStruct.CustomFields = resp.CustomFields + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Create Ticket +type TaskCreateTicketInput struct { + // Only one is needed: requester-id or email + RequesterID int64 `json:"requester-id"` + Email string `json:"email"` + Subject string `json:"subject"` + Description string `json:"description"` + Source string `json:"source"` + Status string `json:"status"` + Priority string `json:"priority"` + Type string `json:"ticket-type"` + CompanyID int64 `json:"company-id"` + ProductID int64 `json:"product-id"` + GroupID int64 `json:"group-id"` + ResponderID int64 `json:"responder-id"` + Tags []string `json:"tags"` + CCEmails []string `json:"cc-emails"` + ParentID int64 `json:"parent-id"` + RelatedTicketIDs []int64 `json:"related-ticket-ids"` +} + +type TaskCreateTicketReq struct { + RequesterID int64 `json:"requester_id,omitempty"` + Email string `json:"email,omitempty"` + Subject string `json:"subject"` + Description string `json:"description"` + Source int `json:"source"` + Status int `json:"status"` + Priority int `json:"priority"` + Type string `json:"type,omitempty"` + CompanyID int64 `json:"company_id,omitempty"` + ProductID int64 `json:"product_id,omitempty"` + GroupID int64 `json:"group_id,omitempty"` + ResponderID int64 `json:"responder_id,omitempty"` + Tags []string `json:"tags,omitempty"` + CCEmails []string `json:"cc_emails,omitempty"` + ParentID int64 `json:"parent_id,omitempty"` + RelatedTicketIDs []int64 `json:"related_ticket_ids,omitempty"` +} + +type TaskCreateTicketResponse struct { + ID int64 `json:"id"` + CreatedAt string `json:"created_at"` +} + +type TaskCreateTicketOutput struct { + ID int64 `json:"ticket-id"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskCreateTicket(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskCreateTicketInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + if inputStruct.ParentID != 0 && len(inputStruct.RelatedTicketIDs) > 0 { + return nil, fmt.Errorf("only one of parent-id or related-ticket-ids can be provided") + } + + req := TaskCreateTicketReq{ + Subject: inputStruct.Subject, + Description: inputStruct.Description, + Source: convertSourceToInt(inputStruct.Source), + Status: convertStatusToInt(inputStruct.Status), + Priority: convertPriorityToInt(inputStruct.Priority), + Type: inputStruct.Type, + CompanyID: inputStruct.CompanyID, + ProductID: inputStruct.ProductID, + GroupID: inputStruct.GroupID, + ResponderID: inputStruct.ResponderID, + Tags: inputStruct.Tags, + CCEmails: inputStruct.CCEmails, + } + + if inputStruct.RequesterID != 0 { + req.RequesterID = inputStruct.RequesterID + } else if inputStruct.Email != "" { + req.Email = inputStruct.Email + } else { + return nil, fmt.Errorf("either Requester ID or email is required") + } + + if inputStruct.ParentID != 0 { + req.ParentID = inputStruct.ParentID + } + + if len(inputStruct.RelatedTicketIDs) > 0 { + req.RelatedTicketIDs = inputStruct.RelatedTicketIDs + } + + resp, err := e.client.CreateTicket(&req) + if err != nil { + return nil, err + } + + outputStruct := TaskCreateTicketOutput{ + ID: resp.ID, + CreatedAt: convertTimestampResp(resp.CreatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 3: Reply To A Ticket + +type TaskReplyToTicketInput struct { + TicketID int64 `json:"ticket-id"` + Body string `json:"body"` + FromEmail string `json:"from-email"` + UserID int64 `json:"user-id"` //user ID can either be the requester or the agent + CCEmails []string `json:"cc-emails"` + BCCEmails []string `json:"bcc-emails"` +} + +type TaskReplyToTicketReq struct { + Body string `json:"body"` + FromEmail string `json:"from_email,omitempty"` + UserID int64 `json:"user_id,omitempty"` + CCEmails []string `json:"cc_emails,omitempty"` + BCCEmails []string `json:"bcc_emails,omitempty"` +} + +type TaskReplyToTicketResponse struct { + ConversationID int64 `json:"id"` + CreatedAt string `json:"created_at"` +} + +type TaskReplyToTicketOutput struct { + ConversationID int64 `json:"conversation-id"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskReplyToTicket(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskReplyToTicketInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + req := TaskReplyToTicketReq{ + Body: inputStruct.Body, + FromEmail: inputStruct.FromEmail, + UserID: inputStruct.UserID, + CCEmails: inputStruct.CCEmails, + BCCEmails: inputStruct.BCCEmails, + } + + resp, err := e.client.ReplyToTicket(inputStruct.TicketID, &req) + + if err != nil { + return nil, err + } + + outputStruct := TaskReplyToTicketOutput{ + ConversationID: resp.ConversationID, + CreatedAt: convertTimestampResp(resp.CreatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 4: Create Ticket Note + +type TaskCreateTicketNoteInput struct { + TicketID int64 `json:"ticket-id"` + Body string `json:"body"` + NotifyEmails []string `json:"notify-emails"` + UserID int64 `json:"user-id"` + Private bool `json:"private"` + Incoming bool `json:"incoming"` +} + +type TaskCreateTicketNoteReq struct { + Body string `json:"body"` + NotifyEmails []string `json:"notify_emails,omitempty"` + UserID int64 `json:"user_id,omitempty"` + Private bool `json:"private"` + Incoming bool `json:"incoming"` +} + +type TaskCreateTicketNoteResponse struct { + ConversationID int64 `json:"id"` + CreatedAt string `json:"created_at"` +} + +type TaskCreateTicketNoteOutput struct { + ConversationID int64 `json:"conversation-id"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskCreateTicketNote(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskCreateTicketNoteInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + req := TaskCreateTicketNoteReq{ + Body: inputStruct.Body, + NotifyEmails: inputStruct.NotifyEmails, + UserID: inputStruct.UserID, + Private: inputStruct.Private, + Incoming: inputStruct.Incoming, + } + + resp, err := e.client.CreateTicketNote(inputStruct.TicketID, &req) + + if err != nil { + return nil, err + } + + outputStruct := TaskCreateTicketNoteOutput{ + ConversationID: resp.ConversationID, + CreatedAt: convertTimestampResp(resp.CreatedAt), + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert output to struct: %v", err) + } + + return output, nil +} + +// Task 5: Get Conversations + +type TaskGetAllConversationsInput struct { + TicketID int64 `json:"ticket-id"` +} + +type TaskGetAllConversationsResponse struct { + BodyText string `json:"body_text"` + ConversationID int64 `json:"id"` + SupportEmail string `json:"support_email"` + ToEmails []string `json:"to_emails"` + FromEmail string `json:"from_email"` + CCEmails []string `json:"cc_emails"` + BCCEmails []string `json:"bcc_emails"` + Incoming bool `json:"incoming"` + Private bool `json:"private"` + UserID int64 `json:"user_id"` + CreatedAt string `json:"created_at"` +} + +type TaskGetAllConversationsOutput struct { + Conversations []taskGetAllConversationsOutputConversation `json:"conversations"` + ConversationsLength int `json:"conversations-length"` +} + +type taskGetAllConversationsOutputConversation struct { + BodyText string `json:"body-text"` + ConversationID int64 `json:"conversation-id"` + SupportEmail string `json:"support-email,omitempty"` + ToEmails []string `json:"to-emails"` + FromEmail string `json:"from-email,omitempty"` + CCEmails []string `json:"cc-emails"` + BCCEmails []string `json:"bcc-emails"` + Incoming bool `json:"incoming"` + Private bool `json:"private"` + UserID int64 `json:"user-id,omitempty"` + CreatedAt string `json:"created-at"` +} + +func (e *execution) TaskGetAllConversations(in *structpb.Struct) (*structpb.Struct, error) { + inputStruct := TaskGetAllConversationsInput{} + err := base.ConvertFromStructpb(in, &inputStruct) + + if err != nil { + return nil, fmt.Errorf("failed to convert input to struct: %v", err) + } + + outputStruct := TaskGetAllConversationsOutput{} + + var resp []TaskGetAllConversationsResponse + var paginationPath string + + for { + + if paginationPath == "" { + resp, paginationPath, err = e.client.GetAllConversations(inputStruct.TicketID, false, "") + } else { + resp, paginationPath, err = e.client.GetAllConversations(inputStruct.TicketID, true, paginationPath) + } + + if err != nil { + return nil, err + } + + for _, conversation := range resp { + outputConvo := taskGetAllConversationsOutputConversation{ + BodyText: conversation.BodyText, + ConversationID: conversation.ConversationID, + SupportEmail: conversation.SupportEmail, + ToEmails: *checkForNilString(&conversation.ToEmails), + FromEmail: conversation.FromEmail, + CCEmails: *checkForNilString(&conversation.CCEmails), + BCCEmails: *checkForNilString(&conversation.BCCEmails), + Incoming: conversation.Incoming, + Private: conversation.Private, + UserID: conversation.UserID, + CreatedAt: convertTimestampResp(conversation.CreatedAt), + } + + outputStruct.Conversations = append(outputStruct.Conversations, outputConvo) + } + + if paginationPath == "" { + break + } + } + + outputStruct.ConversationsLength = len(outputStruct.Conversations) + if outputStruct.ConversationsLength == 0 { + outputStruct.Conversations = []taskGetAllConversationsOutputConversation{} + } + + output, err := base.ConvertToStructpb(outputStruct) + + if err != nil { + return nil, err + } + + return output, nil +} + +func convertSourceToString(source int) string { + switch source { + case 1: + return "Email" + case 2: + return "Portal" + case 3: + return "Phone" + case 4: + return "Forum" + case 5: + return "Twitter" + case 6: + return "Facebook" + case 7: + return "Chat" + case 8: + return "MobiHelp" + case 9: + return "Feedback Widget" + case 10: + return "Outbound Email" + case 11: + return "Ecommerce" + case 12: + return "Bot" + case 13: + return "Whatsapp" + default: + return fmt.Sprintf("Unknown source, received: %d", source) + } +} + +func convertSourceToInt(source string) int { + // For creating ticket, the only source that can be used is 1,2,3,5,6,7,9,11,10 + switch source { + case "Email": + return 1 + case "Portal": + return 2 + case "Phone": + return 3 + case "Twitter": + return 5 + case "Facebook": + return 6 + case "Chat": + return 7 + case "Feedback Widget": + return 9 + case "Outbound Email": + return 10 + case "Ecommerce": + return 11 + } + return 0 +} + +func convertStatusToString(status int) string { + switch status { + case 2: + return "Open" + case 3: + return "Pending" + case 4: + return "Resolved" + case 5: + return "Closed" + case 6: + return "Waiting on Customer" + case 7: + return "Waiting on Third Party" + default: + return fmt.Sprintf("Unknown status, received: %d", status) + } +} + +func convertStatusToInt(status string) int { + switch status { + case "Open": + return 2 + case "Pending": + return 3 + case "Resolved": + return 4 + case "Closed": + return 5 + case "Waiting on Customer": + return 6 + case "Waiting on Third Party": + return 7 + } + return 0 +} + +func convertPriorityToString(priority int) string { + switch priority { + case 1: + return "Low" + case 2: + return "Medium" + case 3: + return "High" + case 4: + return "Urgent" + default: + return fmt.Sprintf("Unknown priority, received: %d", priority) + } +} + +func convertPriorityToInt(priority string) int { + switch priority { + case "Low": + return 1 + case "Medium": + return 2 + case "High": + return 3 + case "Urgent": + return 4 + } + return 0 +} + +func convertAssociationType(associationType int) string { + switch associationType { + case 1: + return "Parent" + case 2: + return "Child" + case 3: + return "Tracker" + case 4: + return "Related" + default: + return "No association" + } +} diff --git a/application/freshdesk/v0/ticket_test.go b/application/freshdesk/v0/ticket_test.go new file mode 100644 index 00000000..c0edc554 --- /dev/null +++ b/application/freshdesk/v0/ticket_test.go @@ -0,0 +1,459 @@ +package freshdesk + +import ( + "context" + "testing" + + qt "github.com/frankban/quicktest" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" + + "github.com/gojuno/minimock/v3" + "github.com/instill-ai/component/base" + "go.uber.org/zap" +) + +const ( + apiKey = "xxxxxxxxxxxxxxxxxxxx" + domain = "yourdomain" +) + +func TestComponent_ExecuteGetTicketTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetTicketMock. + When(12). + Then(&TaskGetTicketResponse{ + Subject: "Test Ticket", + DescriptionText: "This is a test ticket", + Source: 1, + Status: 2, + Priority: 1, + TicketType: "Feature Request", + Tags: []string{"tag1", "tag2"}, + RequesterID: 154023592736, + ProductID: 154000125389, + ToEmails: []string{"test1@gmail.com"}, + Spam: false, + DueBy: "2024-08-28T21:00:00Z", + IsEscalated: false, + FirstResponseDueBy: "2024-08-26T21:00:00Z", + FirstResponseEscalated: true, + SentimentScore: 21, + InitialSentimentScore: 21, + }, nil) + + tc := struct { + name string + input TaskGetTicketInput + wantOutput TaskGetTicketOutput + }{ + name: "ok - task get ticket", + input: TaskGetTicketInput{ + TicketID: 12, + }, + wantOutput: TaskGetTicketOutput{ + Subject: "Test Ticket", + DescriptionText: "This is a test ticket", + Source: "Email", + Status: "Open", + Priority: "Low", + TicketType: "Feature Request", + Tags: []string{"tag1", "tag2"}, + RequesterID: 154023592736, + ProductID: 154000125389, + ToEmails: []string{"test1@gmail.com"}, + Spam: false, + DueBy: "2024-08-28 21:00:00 UTC", + IsEscalated: false, + FirstResponseDueBy: "2024-08-26 21:00:00 UTC", + FirstResponseEscalated: true, + SentimentScore: 21, + InitialSentimentScore: 21, + AssociationType: "No association", + CCEmails: []string{}, + ForwardEmails: []string{}, + ReplyCCEmails: []string{}, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetTicket}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetTicket + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteCreateTicketTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.CreateTicketMock. + When(&TaskCreateTicketReq{ + Subject: "Create Test Ticket", + Description: "Create a test ticket", + Source: 1, + Status: 5, + Priority: 2, + RequesterID: 154023592736, + ProductID: 154000125389, + GroupID: 154000444629, + }). + Then(&TaskCreateTicketResponse{ + ID: 50, + CreatedAt: "2024-08-28T21:00:00Z", + }, nil) + + tc := struct { + name string + input TaskCreateTicketInput + wantOutput TaskCreateTicketOutput + }{ + name: "ok - task create ticket", + input: TaskCreateTicketInput{ + Subject: "Create Test Ticket", + Description: "Create a test ticket", + Source: "Email", + Status: "Closed", + Priority: "Medium", + RequesterID: 154023592736, + ProductID: 154000125389, + GroupID: 154000444629, + }, + wantOutput: TaskCreateTicketOutput{ + ID: 50, + CreatedAt: "2024-08-28 21:00:00 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskCreateTicket}, + client: FreshdeskClientMock, + } + e.execute = e.TaskCreateTicket + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteReplyToTicketTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.ReplyToTicketMock. + When(50, &TaskReplyToTicketReq{ + Body: "This is a test reply to a ticket", + FromEmail: "randomemail@gmail.com", + }). + Then(&TaskReplyToTicketResponse{ + ConversationID: 154041545463, + CreatedAt: "2024-08-28T15:02:20Z", + }, nil) + + tc := struct { + name string + input TaskReplyToTicketInput + wantOutput TaskReplyToTicketOutput + }{ + name: "ok - task reply to ticket", + input: TaskReplyToTicketInput{ + TicketID: 50, + Body: "This is a test reply to a ticket", + FromEmail: "randomemail@gmail.com", + }, + wantOutput: TaskReplyToTicketOutput{ + ConversationID: 154041545463, + CreatedAt: "2024-08-28 15:02:20 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskReplyToTicket}, + client: FreshdeskClientMock, + } + e.execute = e.TaskReplyToTicket + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} + +func TestComponent_ExecuteCreateTicketNoteTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.CreateTicketNoteMock. + When(50, &TaskCreateTicketNoteReq{ + Body: "This is a test note for a ticket", + NotifyEmails: []string{"agentemail@gmail.com"}, + Private: true, + Incoming: false, + }). + Then(&TaskCreateTicketNoteResponse{ + ConversationID: 154041548817, + CreatedAt: "2024-08-28T15:22:48Z", + }, nil) + + tc := struct { + name string + input TaskCreateTicketNoteInput + wantOutput TaskCreateTicketNoteOutput + }{ + name: "ok - task create ticket note", + input: TaskCreateTicketNoteInput{ + TicketID: 50, + Body: "This is a test note for a ticket", + NotifyEmails: []string{"agentemail@gmail.com"}, + Private: true, + Incoming: false, + }, + wantOutput: TaskCreateTicketNoteOutput{ + ConversationID: 154041548817, + CreatedAt: "2024-08-28 15:22:48 UTC", + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskCreateTicketNote}, + client: FreshdeskClientMock, + } + e.execute = e.TaskCreateTicketNote + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) + +} + +func TestComponent_ExecuteGetAllConversationsTask(t *testing.T) { + mc := minimock.NewController(t) + c := qt.New(t) + bc := base.Component{Logger: zap.NewNop()} + connector := Init(bc) + ctx := context.Background() + + FreshdeskClientMock := NewFreshdeskInterfaceMock(mc) + + FreshdeskClientMock.GetAllConversationsMock. + When(50, false, ""). + Then([]TaskGetAllConversationsResponse{ + { + BodyText: "Conversation - a reply", + ConversationID: 154041545463, + Private: false, + Incoming: false, + ToEmails: []string{"randomemail@gmail.com"}, + FromEmail: "theonewhoaddorreply@gmail.com", + CCEmails: []string{}, + BCCEmails: []string{}, + UserID: 154023114553, + CreatedAt: "2024-08-28T15:02:20Z", + }, + { + BodyText: "Conversation - a note", + ConversationID: 154041548817, + Private: false, + Incoming: false, + ToEmails: []string{}, // normally empty for a note + CCEmails: []string{}, + BCCEmails: []string{}, + UserID: 154023114553, + CreatedAt: "2024-08-28T15:22:48Z", + }, + }, "", nil) + + tc := struct { + name string + input TaskGetAllConversationsInput + wantOutput TaskGetAllConversationsOutput + }{ + name: "ok - task get all conversations", + input: TaskGetAllConversationsInput{ + TicketID: 50, + }, + wantOutput: TaskGetAllConversationsOutput{ + Conversations: []taskGetAllConversationsOutputConversation{ + { + BodyText: "Conversation - a reply", + ConversationID: 154041545463, + Private: false, + Incoming: false, + ToEmails: []string{"randomemail@gmail.com"}, + FromEmail: "theonewhoaddorreply@gmail.com", + CCEmails: []string{}, + BCCEmails: []string{}, + UserID: 154023114553, + CreatedAt: "2024-08-28 15:02:20 UTC", + }, + { + BodyText: "Conversation - a note", + ConversationID: 154041548817, + Private: false, + Incoming: false, + ToEmails: []string{}, // normally empty for a note + CCEmails: []string{}, + BCCEmails: []string{}, + UserID: 154023114553, + CreatedAt: "2024-08-28 15:22:48 UTC", + }, + }, + ConversationsLength: 2, + }, + } + + c.Run(tc.name, func(c *qt.C) { + setup, err := structpb.NewStruct(map[string]any{ + "api-key": apiKey, + "domain": domain, + }) + c.Assert(err, qt.IsNil) + + e := &execution{ + ComponentExecution: base.ComponentExecution{Component: connector, SystemVariables: nil, Setup: setup, Task: taskGetAllConversations}, + client: FreshdeskClientMock, + } + e.execute = e.TaskGetAllConversations + + pbIn, err := base.ConvertToStructpb(tc.input) + c.Assert(err, qt.IsNil) + + ir, ow, eh, job := base.GenerateMockJob(c) + ir.ReadMock.Return(pbIn, nil) + ow.WriteMock.Optional().Set(func(ctx context.Context, output *structpb.Struct) (err error) { + + outJSON, err := protojson.Marshal(output) + c.Assert(err, qt.IsNil) + + c.Check(outJSON, qt.JSONEquals, tc.wantOutput) + return nil + }) + eh.ErrorMock.Optional() + + err = e.Execute(ctx, []*base.Job{job}) + + c.Assert(err, qt.IsNil) + + }) +} diff --git a/store/store.go b/store/store.go index d37c2dd2..3e433e00 100644 --- a/store/store.go +++ b/store/store.go @@ -20,6 +20,7 @@ import ( "github.com/instill-ai/component/ai/openai/v0" "github.com/instill-ai/component/ai/stabilityai/v0" "github.com/instill-ai/component/application/email/v0" + "github.com/instill-ai/component/application/freshdesk/v0" "github.com/instill-ai/component/application/github/v0" "github.com/instill-ai/component/application/googlesearch/v0" "github.com/instill-ai/component/application/hubspot/v0" @@ -183,6 +184,7 @@ func Init( compStore.Import(ollama.Init(baseComp)) compStore.Import(hubspot.Init(baseComp)) compStore.Import(whatsapp.Init(baseComp)) + compStore.Import(freshdesk.Init(baseComp)) }) return compStore