Skip to content

Commit ae5d9f0

Browse files
authored
Merge pull request #27 from jolicode/feature/spec-update-20230817
Feature/spec update 20230817
2 parents d767707 + 9515a1e commit ae5d9f0

File tree

2 files changed

+78
-11
lines changed

2 files changed

+78
-11
lines changed

generated/harvest-openapi.yaml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ components:
253253
nullable: true
254254
include_link_to_client_invoice:
255255
type: boolean
256-
description: 'Whether to include a link to the client invoice in the message body. Not used when thank_you is true.'
256+
description: 'DEPRECATED This will be true when payment_options are assigned to the invoice and false when there are no payment_options.'
257257
nullable: true
258+
deprecated: true
258259
attach_pdf:
259260
type: boolean
260261
description: 'Whether to attach the invoice PDF to the message email.'
@@ -515,6 +516,16 @@ components:
515516
type: string
516517
description: 'The timeframe in which the invoice should be paid. Options: upon receipt, net 15, net 30, net 45, net 60, or custom.'
517518
nullable: true
519+
payment_options:
520+
type: array
521+
description: 'The list of payment options enabled for the invoice. Options: [ach, credit_card, paypal]'
522+
nullable: true
523+
items:
524+
type: string
525+
enum:
526+
- ach
527+
- credit_card
528+
- paypal
518529
sent_at:
519530
type: string
520531
description: 'Date and time the invoice was sent.'
@@ -1152,7 +1163,6 @@ components:
11521163
type: integer
11531164
description: 'Unique ID for the time entry.'
11541165
nullable: true
1155-
format: int32
11561166
spent_date:
11571167
type: string
11581168
description: 'Date of the time entry.'
@@ -1619,7 +1629,7 @@ components:
16191629
url: 'https://help.getharvest.com/api-v2/users-api/users/teammates/#the-teammate-object'
16201630
properties:
16211631
id:
1622-
type: int
1632+
type: integer
16231633
description: 'Unique ID for the teammate'
16241634
nullable: true
16251635
first_name:
@@ -6130,6 +6140,8 @@ paths:
61306140
created_at: '2017-06-27T16:27:16Z'
61316141
updated_at: '2017-08-23T22:25:59Z'
61326142
currency: EUR
6143+
payment_options:
6144+
- credit_card
61336145
client:
61346146
id: 5735776
61356147
name: '123 Industries'
@@ -6338,6 +6350,8 @@ paths:
63386350
created_at: '2017-06-27T16:34:24Z'
63396351
updated_at: '2017-06-27T16:34:24Z'
63406352
currency: USD
6353+
payment_options:
6354+
- credit_card
63416355
client:
63426356
id: 5735774
63436357
name: 'ABC Corp'
@@ -6430,6 +6444,16 @@ paths:
64306444
type: string
64316445
description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, net 60, or custom.'
64326446
nullable: true
6447+
payment_options:
6448+
type: array
6449+
description: 'The payment options available to pay the invoice. Your account must be configured with the appropriate options under Settings > Integrations > Online payment to assign them. Options: [ach, credit_card, paypal]'
6450+
nullable: true
6451+
items:
6452+
type: string
6453+
enum:
6454+
- ach
6455+
- credit_card
6456+
- paypal
64336457
line_items_import:
64346458
type: object
64356459
description: 'An line items import object'
@@ -6481,7 +6505,7 @@ paths:
64816505
description: 'If set to true, a PDF containing an expense report with receipts will be attached to the invoice. Defaults to false.'
64826506
retainer_id:
64836507
type: integer
6484-
description: 'The ID of the retainer you want to add funds to with this invoice. Note: retainers cannot be fully used (created, drawn against, closed, etc.) via the API at this time. The only avaiable action is to add funds.'
6508+
description: 'The ID of the retainer you want to add funds to with this invoice. Note: retainers cannot be fully used (created, drawn against, closed, etc.) via the API at this time. The only available action is to add funds.'
64856509
nullable: true
64866510
format: int32
64876511
line_items:
@@ -6595,6 +6619,8 @@ paths:
65956619
created_at: '2017-06-27T16:24:30Z'
65966620
updated_at: '2017-06-27T16:24:57Z'
65976621
currency: USD
6622+
payment_options:
6623+
- credit_card
65986624
client:
65996625
id: 5735776
66006626
name: '123 Industries'
@@ -6678,6 +6704,8 @@ paths:
66786704
created_at: '2017-06-27T16:34:24Z'
66796705
updated_at: '2017-06-27T16:36:33Z'
66806706
currency: USD
6707+
payment_options:
6708+
- credit_card
66816709
client:
66826710
id: 5735774
66836711
name: 'ABC Corp'
@@ -6782,6 +6810,16 @@ paths:
67826810
type: string
67836811
description: 'The timeframe in which the invoice should be paid. Options: upon receipt, net 15, net 30, net 45, or net 60.'
67846812
nullable: true
6813+
payment_options:
6814+
type: array
6815+
description: 'The payment options available to pay the invoice. Your account must be configured with the appropriate options under Settings > Integrations > Online payment to assign them. Options: [ach, credit_card, paypal]'
6816+
nullable: true
6817+
items:
6818+
type: string
6819+
enum:
6820+
- ach
6821+
- credit_card
6822+
- paypal
67856823
line_items:
67866824
type: array
67876825
description: 'Array of line item parameters'
@@ -7029,8 +7067,9 @@ paths:
70297067
nullable: true
70307068
include_link_to_client_invoice:
70317069
type: boolean
7032-
description: 'If set to true, a link to the client invoice URL will be included in the message email. Defaults to false. Ignored when thank_you is set to true.'
7070+
description: 'DEPRECATED A link to the client invoice URL will be automatically included in the message email if payment_options have been assigned to the invoice. Setting to true will be ignored. Setting to false will clear all payment_options on the invoice.'
70337071
nullable: true
7072+
deprecated: true
70347073
attach_pdf:
70357074
type: boolean
70367075
description: 'If set to true, a PDF of the invoice will be attached to the message email. Defaults to false.'
@@ -12800,8 +12839,10 @@ paths:
1280012839
type: object
1280112840
properties:
1280212841
teammate_ids:
12803-
type: 'array of user ids'
12842+
type: array
1280412843
description: 'Full list of user IDs to be assigned to the Manager.'
1280512844
nullable: true
12845+
items:
12846+
type: string
1280612847
required:
1280712848
- teammate_ids

src/Extractor/Extractor.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,21 @@ public static function buildDefinitionProperty($name, $type, $description, $path
101101
$arrayof = 'string';
102102
}
103103

104+
if ('array of user ids' === $type) {
105+
$arrayof = 'string';
106+
}
107+
104108
if (null !== $arrayof) {
105109
$property['items'] = ['type' => $arrayof];
110+
} else if ('array' === $type && 'payment_options' === $name) {
111+
$property['items'] = [
112+
'type' => 'string',
113+
'enum' => [
114+
'ach',
115+
'credit_card',
116+
'paypal',
117+
],
118+
];
106119
}
107120

108121
if ('Array of recipient parameters. See below for details.' === $description) {
@@ -375,6 +388,10 @@ public static function buildDefinitionProperty($name, $type, $description, $path
375388
}
376389
}
377390

391+
if (str_starts_with($description, 'DEPRECATED')) {
392+
$property['deprecated'] = true;
393+
}
394+
378395
return $property;
379396
}
380397

@@ -502,8 +519,16 @@ public static function buildRequestBody($method, $path, $explicitParameters, $ex
502519
$$columnName = array_shift($explicitParameters);
503520
}
504521

505-
if (isset($required) && 'required' === $required) {
506-
$requiredProperties[] = $parameter;
522+
if (isset($required)) {
523+
if ('*optional' === $required) {
524+
$required = 'optional';
525+
}
526+
527+
if ('required' === $required) {
528+
$requiredProperties[] = $parameter;
529+
} else if (!\in_array($required, ['optional', 'required'])) {
530+
$description = $required;
531+
}
507532
}
508533

509534
$property = self::buildDefinitionProperty($parameter, $type, $description, $path, $method);
@@ -632,7 +657,9 @@ public static function camelize($word)
632657
public static function convertType($type)
633658
{
634659
$conversionMap = [
660+
'bigint' => 'integer',
635661
'file' => 'string',
662+
'int' => 'integer',
636663
'long' => 'integer',
637664
'decimal' => 'number',
638665
'float' => 'number',
@@ -643,6 +670,7 @@ public static function convertType($type)
643670
'dateTime' => 'string',
644671
'array of integers' => 'array',
645672
'array of strings' => 'array',
673+
'array of user ids' => 'array',
646674
];
647675

648676
return isset($conversionMap[$type]) ? $conversionMap[$type] : $type;
@@ -891,9 +919,7 @@ private function buildItemsTypes()
891919
if (isset($property['items']) && isset($property['items']['type'])) {
892920
if (isset($this->definitions[$property['items']['type']])) {
893921
$this->definitions[$definitionName]['properties'][$propertyName]['items'] = ['$ref' => '#/components/schemas/'.$property['items']['type']];
894-
} elseif (\in_array($property['items']['type'], self::BASE_TYPES, true)) {
895-
$this->definitions[$definitionName]['properties'][$propertyName]['items'] = ['type' => $property['items']['type']];
896-
} else {
922+
} else if (!\in_array($property['items']['type'], self::BASE_TYPES, true)) {
897923
echo $property['items']['type']."\n";
898924
}
899925
}

0 commit comments

Comments
 (0)