Skip to content

Commit

Permalink
Fix titles and indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Apr 22, 2020
1 parent 91b2aa8 commit 79f7d39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Expand Up @@ -6,7 +6,7 @@ weight: 4

# Create a resource

### Creation workflow
## Creation workflow

The creation workflow is a bit more complex than reading some data from the API, mainly because we rarely manage data via XML format. In most use cases the user is presented with a human understandable component, like a form, and the data entered is then processed. Besides we need to make sure that the XML sent to the webservice is understandable and complete.

Expand All @@ -16,7 +16,7 @@ As we explained in a previous tutorial the webservice provides two [resource sch

> You can update this schema using the [source XML file](/schemas/1.7/create-resource.xml) importable in services like [draw.io](https://draw.io).
### Retrieve the blank schema
## Retrieve the blank schema

We already saw that the get method can be used to retrieve either a list or a specific resource (with the `resource` and `id` parameters) but it can only be used to get a specific `url`

Expand All @@ -37,7 +37,7 @@ try {
}
```

### Fill the schema and create new resource
## Fill the schema and create new resource

Now that you have the empty XML structure you can fill it with your data, once it is done you will use the `add()` method to create the new resource.

Expand Down
Expand Up @@ -15,7 +15,7 @@ As we saw in the previous code sample, we need the `get()` method to retrieve an
| **resource** | customers |


### Using PrestaShopWebservice::get
## Using PrestaShopWebservice::get

```php
try {
Expand All @@ -30,7 +30,7 @@ try {
}
```

### Returned data
## Returned data

The returned object is a `SimpleXMLElement` object containing this kind of data:

Expand All @@ -44,7 +44,7 @@ The returned object is a `SimpleXMLElement` object containing this kind of data:
</prestashop>
```

### Access children data
## Access children data

You can now loop through this XML object to get each customer ID

Expand Down
Expand Up @@ -25,7 +25,7 @@ We are going to use the same `get()` method but provide an additional `id` param
| **resource** | customers |
| **id** | *resource_id* (int) |

### Using PrestaShopWebservice::get
## Using PrestaShopWebservice::get

```php
try {
Expand All @@ -43,7 +43,7 @@ try {
}
```

### Returned data
## Returned data

You will receive the same xml as if you request http://example.com/api/customers/1 in your browser:

Expand Down Expand Up @@ -87,15 +87,15 @@ You will receive the same xml as if you request http://example.com/api/customers
<associations>
<groups nodeType="group" api="groups">
<group xlink:href="http://local.prestashop-177/api/groups/3">
<id><![CDATA[3]]></id>
<id><![CDATA[3]]></id>
</group>
</groups>
</associations>
</customer>
</prestashop>
```

### Access resource fields
## Access resource fields

You can now loop through this XML object to get each customer field value, or access specific fields individually

Expand Down
Expand Up @@ -6,15 +6,15 @@ weight: 5

# Update a resource

### Update workflow
## Update workflow

The update workflow is quite similar to the [creation workflow](/1.7/development/webservice/tutorials/6-create-resource/#creation-workflow), the main difference is that the initial input is not a blank XML but an existing one, so we use the `get()` method to get a prefilled XML, and then we can update its fields.

{{< figure src="../../../img/update-resource.png" title="Update Resource via Webservice" >}}

> You can update this schema using the [source XML file](/schemas/1.7/update-resource.xml) importable in services like [draw.io](https://draw.io).
### Retrieve the resource
## Retrieve the resource

```php
try {
Expand All @@ -32,7 +32,7 @@ try {
}
```

### Fill the schema and update resource
## Fill the schema and update resource

Quite similar to the resource creation, except we can update only some fields (since the other are already present) and we use the `edit()` method.

Expand Down

0 comments on commit 79f7d39

Please sign in to comment.