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

Develop #819

Merged
merged 15 commits into from
Feb 5, 2024
Merged
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
13 changes: 2 additions & 11 deletions .github/workflows/generate-zapier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,10 @@ jobs:
run: |
echo "openapi_version=$OPENAPI_VERSION"

BUMP_TYPE=$(node ./scripts/sdk-version-checker.js ./generated/zapier/version.yaml $OPENAPI_VERSION)

cd ./generated/zapier

if [ "$BUMP_TYPE" == "patch" ];then
echo 'Bumping the patch version...'
standard-version --skip.tag --skip.changelog --skip.commit --release-as patch
elif [ "$BUMP_TYPE" == "openapi" ];then
echo 'Using the openapi version...'
standard-version --skip.tag --skip.changelog --skip.commit --release-as $OPENAPI_VERSION
else
echo "Something bad happened - impossible to bump the version. value=$BUMP_TYPE"
fi
echo 'Bumping the patch version...'
standard-version --skip.tag --skip.changelog --skip.commit --release-as patch

INTEGRATION_VERSION=$(yq e '.info.version' ./version.yaml)

Expand Down
1 change: 1 addition & 0 deletions models/enums/FattureInCloudPlanType.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ enum:
- standard
- premium
- premium_plus
- complete
7 changes: 7 additions & 0 deletions models/responses/GetCompanyPlanUsageResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: GetCompanyPlanUsageResponse
description: ''
type: object
properties:
data:
$ref: ../schemas/CompanyPlanUsage.yaml
nullable: true
6 changes: 6 additions & 0 deletions models/schemas/Company.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ properties:
nullable: true
items:
$ref: ./ControlledCompany.yaml
fic_license_expire:
type: string
format: date
nullable: true
fic_plan:
$ref: ../enums/FattureInCloudPlanType.yaml
connection_id:
type: integer
description: Company connection id
Expand Down
6 changes: 6 additions & 0 deletions models/schemas/CompanyInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ properties:
type: boolean
nullable: true
description: Company activated through accountant
fic_license_expire:
type: string
format: date
nullable: true
fic_plan_name:
$ref: ../enums/FattureInCloudPlanType.yaml
plan_info:
type: object
nullable: true
Expand Down
11 changes: 11 additions & 0 deletions models/schemas/CompanyPlanUsage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: CompanyPlanUsage
type: object
properties:
limit:
type: number
description: Plan limit
nullable: true
usage:
type: number
description: Plan usage
nullable: true
6 changes: 6 additions & 0 deletions models/schemas/ControlledCompany.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ properties:
example: >-
fd015011d2dbf8a9d38e810b325b11b56d02e51688e5261a245933b8e677b8b44ff5f0fe5ccaaf1d7157fa13ca72ab62b6183db0667a576a0e19164801c18c4fd81273fc1f95bf460b869015cf99acba
nullable: true
fic_license_expire:
type: string
format: date
nullable: true
fic_plan:
$ref: ../enums/FattureInCloudPlanType.yaml
connection_id:
type: number
description: Controlled company connection id
Expand Down
45 changes: 40 additions & 5 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,34 @@ paths:
- OAuth2AuthenticationCodeFlow: []
tags:
- Companies
/c/{company_id}/company/plan_usage:
parameters:
- $ref: '#/components/parameters/company_id'
get:
summary: Get Company Plan Usage
responses:
'200':
$ref: '#/components/responses/GetCompanyPlanUsageResponse'
'401':
description: Unauthorized.
operationId: getCompanyPlanUsage
description: Gets the company limits usage.
parameters:
- schema:
type: string
enum:
- clients
- suppliers
- products
- documents
in: query
name: category
description: Category
required: true
security:
- OAuth2AuthenticationCodeFlow: []
tags:
- Companies
/c/{company_id}/entities/clients:
parameters:
- $ref: '#/components/parameters/company_id'
Expand Down Expand Up @@ -4182,7 +4210,6 @@ components:
locked: false
has_ts_pay_pending_payment: false
show_tspay_button: false
pay_with_tspay_url: null
GetIssuedDocumentResponse:
description: Document Details.
content:
Expand Down Expand Up @@ -4305,7 +4332,6 @@ components:
locked: false
has_ts_pay_pending_payment: false
show_tspay_button: false
pay_with_tspay_url: null
ModifyIssuedDocumentResponse:
description: Document edited
content:
Expand Down Expand Up @@ -4429,7 +4455,6 @@ components:
locked: false
has_ts_pay_pending_payment: false
show_tspay_button: false
pay_with_tspay_url: null
GetNewIssuedDocumentTotalsResponse:
description: Totals.
content:
Expand Down Expand Up @@ -8662,7 +8687,6 @@ components:
locked: false
has_ts_pay_pending_payment: false
show_tspay_button: false
pay_with_tspay_url: null
options:
create_from:
- '82112399'
Expand Down Expand Up @@ -8789,7 +8813,6 @@ components:
locked: false
has_ts_pay_pending_payment: false
show_tspay_button: false
pay_with_tspay_url: null
options:
create_from:
- '82112399'
Expand Down Expand Up @@ -8922,5 +8945,17 @@ components:
warnings: >-
The 'it.fattureincloud.webhooks.entities.clients.delete' event
is already registered for this application
GetCompanyPlanUsageResponse:
description: Example response
content:
application/json:
schema:
$ref: ./models/responses/GetCompanyPlanUsageResponse.yaml
examples:
example-1:
value:
data:
limit: 3000
usage: 100
security:
- OAuth2AuthenticationCodeFlow: []
2 changes: 1 addition & 1 deletion templates/openapi-generator/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
{{#imports}} "{{import}}"
{{/imports}}
. "github.com/fattureincloud/fattureincloud-go-sdk/v2/model"
. "github.com/fattureincloud/fattureincloud-go-sdk/v2/model"
)

{{#generateInterfaces}}
Expand Down
2 changes: 1 addition & 1 deletion templates/openapi-generator/go/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"
"unicode/utf8"
. "github.com/fattureincloud/fattureincloud-go-sdk/v2/model"
. "github.com/fattureincloud/fattureincloud-go-sdk/v2/model"

{{#hasOAuthMethods}}
"golang.org/x/oauth2"
Expand Down
2 changes: 1 addition & 1 deletion templates/openapi-generator/ruby/gemspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
s.add_runtime_dependency 'faraday-multipart'
{{/isFaraday}}
{{^isTyphoeus}}
{{#isTyphoeus}}
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
{{/isTyphoeus}}
{{#isHttpx}}
Expand Down
7 changes: 5 additions & 2 deletions templates/openapi-generator/zapier/index.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const authentication = require('./authentication');
const { searchActions, createActions } = require('./operations/actions');
const { triggers } = require('./operations/triggers');
const { overrideUserAgent } = require('./utils/utils');
const { overrideUserAgent, handleClientErrors } = require('./utils/utils');

module.exports = {
version: require('./package.json').version,
Expand All @@ -12,5 +12,8 @@ module.exports = {
creates: createActions(),
beforeRequest: [
overrideUserAgent,
]
],
afterResponse: [
handleClientErrors,
],
};
23 changes: 21 additions & 2 deletions templates/openapi-generator/zapier/utils.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,32 @@ const searchMiddleware = (action) => {
return action
}
const extractResourceAndOperation = (eventType) => ({
resource: eventType.substring('it.fattureincloud.webhooks.'.length, eventType.lastIndexOf('.')),
eventOperation: eventType.substring(eventType.lastIndexOf('.') + 1)
resource: eventType.substring('it.fattureincloud.webhooks.'.length, eventType.lastIndexOf('.')),
eventOperation: eventType.substring(eventType.lastIndexOf('.') + 1)
})
const retrieveResourceOperations = (resource) => EventType.fields('').choices.filter(eventType => extractResourceAndOperation(eventType).resource == resource).map(et => ({type: extractResourceAndOperation(et).eventOperation, id: extractResourceAndOperation(et).eventOperation}))
const overrideUserAgent = (request, z, bundle) => {
request.headers['user-agent'] = `FattureInCloud/${require('../package.json').version}/Zapier`
return request
}
const handleClientErrors = (response, z) => {
if (response.status >= 400 && response.status < 500) {
let errorMessage = JSON.stringify(response.json)

if (!_.isEmpty(response.json?.error?.validation_result)) {
errorMessage = Object.keys(response.json?.error?.validation_result)
.map(key => `[${key}]: ${response.json.error.validation_result[key].join(' - ')}`)
.join('\n')
} else if (!_.isEmpty(response.json?.error?.message)) {
errorMessage = response.json.error.message
}

throw new z.errors.Error(
errorMessage
);
}
return response;
}
const jsonFieldToObject = (val, fieldname) => {
if (_.isEmpty(val)) return undefined
try {
Expand All @@ -65,5 +83,6 @@ module.exports = {
extractResourceAndOperation: extractResourceAndOperation,
retrieveResourceOperations: retrieveResourceOperations,
overrideUserAgent: overrideUserAgent,
handleClientErrors: handleClientErrors,
jsonFieldToObject: jsonFieldToObject,
}
Loading