mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Updated fields api documentation
This commit is contained in:
78
API.md
78
API.md
@@ -47,8 +47,6 @@ ___
|
|||||||
* Getting remote resources
|
* Getting remote resources
|
||||||
* [.load()](#method_load)
|
* [.load()](#method_load)
|
||||||
* [Setting Pass Structure Keys (primaryFields, secondaryFields, ...)](#prop_fields)
|
* [Setting Pass Structure Keys (primaryFields, secondaryFields, ...)](#prop_fields)
|
||||||
* [<field>.push()](#prop_fields-push)
|
|
||||||
* [<field>.pop()](#prop_fields-pop)
|
|
||||||
* [TransitType](#prop_transitType)
|
* [TransitType](#prop_transitType)
|
||||||
* Generating the compiled pass.
|
* Generating the compiled pass.
|
||||||
* [.generate()](#method_generate)
|
* [.generate()](#method_generate)
|
||||||
@@ -448,34 +446,9 @@ ___
|
|||||||
**Setting Pass Structure Keys (primaryFields, secondaryFields, ...)**:
|
**Setting Pass Structure Keys (primaryFields, secondaryFields, ...)**:
|
||||||
___
|
___
|
||||||
|
|
||||||
Unlike method-set properties or overrides, to set fields inside areas (*primaryFields*, *secondaryFields*, *auxiliaryFields*, *headerFields*, *backFields*), this library make available a dedicated array-like interface, with just the essential methods: `push()` and `pop()`.
|
Unlike method-set properties or overrides, to set fields inside areas (*primaryFields*, *secondaryFields*, *auxiliaryFields*, *headerFields*, *backFields*), this library make available a dedicated interface that extends native Array, to let you perform all the operations you need on the fields. Still, **shouldOverride** option, will determine whether default inserted fields should be kept or not.
|
||||||
|
|
||||||
<br>
|
**Examples:**
|
||||||
|
|
||||||
<a name="prop_fields-push"></a>
|
|
||||||
|
|
||||||
#### <field>.push()
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
pass.<field>.push(...fields);
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns**:
|
|
||||||
|
|
||||||
`Number - the amount of valid fields added to area`
|
|
||||||
|
|
||||||
**Description**:
|
|
||||||
|
|
||||||
An argument of type "object" is considered as one-element array.
|
|
||||||
Fields are filtered against a schema.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
|
|
||||||
| Key | Type | Description | Optional | Default Value |
|
|
||||||
|-----|------|-------------|----------|:-------------:|
|
|
||||||
| fields | Array\<Object> \| Object | Field to be added to an area | false | -
|
|
||||||
|
|
||||||
**Examples**:
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
pass.headerFields.push({
|
pass.headerFields.push({
|
||||||
@@ -490,55 +463,12 @@ pass.headerFields.push({
|
|||||||
textAlignment: "PKTextAlignmentCenter"
|
textAlignment: "PKTextAlignmentCenter"
|
||||||
});
|
});
|
||||||
|
|
||||||
pass.primaryFields.push({
|
pass.primaryFields.pop();
|
||||||
key: "IATA-source",
|
|
||||||
value: "NAP",
|
|
||||||
label: "Napoli",
|
|
||||||
textAlignment: "PKTextAlignmentLeft"
|
|
||||||
}, {
|
|
||||||
key: "IATA-destination",
|
|
||||||
value: "VCE",
|
|
||||||
label: "Venezia Marco Polo",
|
|
||||||
textAlignment: "PKTextAlignmentRight"
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**See**: [Passkit Package Format Reference # Field Dictionary Keys](https://apple.co/2NuDrUM)
|
**See**: [Passkit Package Format Reference # Field Dictionary Keys](https://apple.co/2NuDrUM)
|
||||||
|
|
||||||
<br>
|
<hr>
|
||||||
|
|
||||||
<a name="prop_fields-pop"></a>
|
|
||||||
|
|
||||||
#### <field>.pop()
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
pass.<field>.pop(amount);
|
|
||||||
```
|
|
||||||
|
|
||||||
**Returns**:
|
|
||||||
|
|
||||||
`Number - the amount of fields removed.`
|
|
||||||
|
|
||||||
**Description**:
|
|
||||||
|
|
||||||
This method is a mix between `Array.prototype.pop` and `Array.prototype.slice`.
|
|
||||||
In fact, passing this method an amount as parameter, will make it act as `slice`. Otherwise it will act as `pop`.
|
|
||||||
|
|
||||||
**Arguments**:
|
|
||||||
|
|
||||||
| Key | Type | Description | Optional | Default Value |
|
|
||||||
|-----|------|-------------|----------|:-------------:|
|
|
||||||
| amount | Number | Amount of fields to be removed from that area | true | -1
|
|
||||||
|
|
||||||
**Examples**:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
pass.secondaryFields.pop(); // last element is popped out.
|
|
||||||
|
|
||||||
pass.backFields.pop(5); // last five elements are popped out.
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<a name="prop_transitType"></a>
|
<a name="prop_transitType"></a>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user