Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an order in Square, retrieve order from Square and create expense report in the Expensify #365

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
$integration: http://ibm.com/appconnect/integration/v2/integrationFile
integration:
type: api
trigger-interfaces:
trigger-interface-1:
triggers:
createCreate_order:
assembly:
$ref: '#/integration/assemblies/assembly-1'
input-context:
data: create_order
output-context:
data: create_order
options:
resources:
- business-object: create_order
model:
$ref: '#/models/create_order'
triggers:
create: createCreate_order
type: api-trigger
action-interfaces:
action-interface-4:
type: api-action
business-object: orders
connector-type: square
actions:
CREATE: {}
action-interface-1:
type: api-action
business-object: orders
connector-type: square
actions:
RETRIEVEALL: {}
action-interface-2:
type: api-action
business-object: postCreateReport_model
connector-type: expensify
actions:
postCreateReport: {}
assemblies:
assembly-1:
assembly:
execute:
- create-action:
name: Square Create order
target:
$ref: '#/integration/action-interfaces/action-interface-4'
map:
mappings:
- customer_id:
template: '{{$Request.idempotency_key}}'
- idempotency_key:
template: '{{$Request.idempotency_key}}'
- line_items:
foreach:
input: '[{}]'
iterator: line_itemsItem
mappings:
- base_price_money:
mappings:
- amount:
expression: '$Request.line_items.amount '
- currency:
template: '{{$Request.line_items.currency}}'
- name:
template: xyz
- quantity:
template: '{{$Request.line_items.quantity}}'
- location_id:
template: LJ21W5C350JKN
$map: http://ibm.com/appconnect/map/v1
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: flowDetails
$ref: '#/flowDetails'
- retrieve-action:
name: Square Retrieve orders
target:
$ref: '#/integration/action-interfaces/action-interface-1'
filter:
where:
and:
- order_id: '{{$SquareCreateorder.order_id}}'
- location_id: LJ21W5C350JKN
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: SquareCreateorder
$ref: '#/node-output/Square Create order/response/payload'
- variable: flowDetails
$ref: '#/flowDetails'
limit: 1
allow-truncation: true
pagination-type: TOKEN
allow-empty-output: false
- custom-action:
name: Expensify Create report
target:
$ref: '#/integration/action-interfaces/action-interface-2'
action: postCreateReport
map:
mappings:
- inputSettings:
mappings:
- employeeEmail:
template: '{{$Request.email}}'
- expenses:
foreach:
input: '$SquareRetrieveorders.line_items '
iterator: expensesItem
mappings:
- amount:
expression: $expensesItem.total_money.amount
- currency:
template: '{{$expensesItem.total_money.currency}}'
- date:
template: '{{$Request.date}}'
- merchant:
template: '{{$Request.email}}'
- policyID:
template: '{{$Request.policy_id}}'
- report:
mappings:
- title:
template: '{{$Request.line_items.name}}'
$map: http://ibm.com/appconnect/map/v1
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: SquareCreateorder
$ref: '#/node-output/Square Create order/response/payload'
- variable: SquareRetrieveorders
$ref: '#/node-output/Square Retrieve orders/response/payload'
- variable: SquareRetrieveordersMetadata
$ref: '#/node-output/Square Retrieve orders/response'
- variable: flowDetails
$ref: '#/flowDetails'
- response:
name: response-1
reply-maps:
- title: create_order successfully created
status-code: 201
map:
$map: http://ibm.com/appconnect/map/v1
input:
- variable: Request
$ref: '#/trigger/payload'
- variable: SquareCreateorder
$ref: '#/node-output/Square Create order/response/payload'
- variable: SquareRetrieveorders
$ref: '#/node-output/Square Retrieve orders/response/payload'
- variable: SquareRetrieveordersMetadata
$ref: '#/node-output/Square Retrieve orders/response'
- variable: ExpensifyCreatereport
$ref: '#/node-output/Expensify Create report/response/payload'
- variable: flowDetails
$ref: '#/flowDetails'
mappings:
- id:
template: '{{$ExpensifyCreatereport.reportID}}'
input: []
name: Usecase1
models:
create_order:
name: create_order
properties:
id:
required: false
id: true
type: string
idempotency_key:
required: false
id: false
type: string
customer_id:
required: false
id: false
type: string
line_items:
required: false
id: false
type:
name:
required: false
id: false
type: string
quantity:
required: false
id: false
type: number
amount:
required: false
id: false
type: string
currency:
required: false
id: false
type: string
email:
required: false
id: false
type: string
date:
required: false
id: false
type: string
policy_id:
required: false
id: false
type: string
plural: create_order
description: ' '
operations:
create: '#/integration/assemblies/assembly-1'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To refer to these instructions while editing the flow, open the [GitHub page](https://github.com/ot4i/app-connect-templates/tree/master/resources/markdown/Create%20an%20order%20in%20Square,%20retrieve%20order%20from%20Square%20and%20create%20expense%20report%20in%20the%20Expensify_instructions.md) (opens in a new window).


1. Click **Create flow** to start using the template.
2. Connect to the following accounts by using your credentials:
- [Square](https://www.ibm.com/docs/en/app-connect/containers_cd?topic=apps-square)
- [Expensify](https://www.ibm.com/docs/en/app-connect/containers_cd?topic=apps-expensify)
3. To start the flow, in the banner, click **Start flow**.

For more information, visit the IBM Integration Community for this use case. See, [Using IBM® App Connect to interact with Expensify](https://community.ibm.com/community/user/integration/blogs/deepak-ayilliath/2023/05/28/using-ibm-app-connect-to-connect-with-expensify).
9 changes: 9 additions & 0 deletions resources/template-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,15 @@
"targetApps": ["hubspotmarketing", "hubspotmarketing", "eventbrite", "hubspotmarketing", "gmail"],
"tags": ["scheduler", "hubspotmarketing", "gmail", "foreach", "eventbrite"],
"offerings": ["app connect professional"]
},
{
"name": "Create an order in Square, retrieve order from Square and create expense report in the Expensify",
"description": "Use this template to create an order in square, retrieve order from Square and create expense report in the Expensify",
"summary": "Square to 2 applications",
"sourceApp": "square",
"targetApps": ["square", "expensify"],
"tags": ["square", "expensify"],
"offerings": ["app connect professional"]
}
]
}
Loading