<commit_before>---
title: Spree Endpoint
---

## Overview

The Spree endpoint is the endpoint that handles all the interaction between the hub and Spree stores. It provides a variety of actions for monitoring different entities, which will be described below.

+++
The source code for the [Spree Endpoint](https://github.com/spree/spree_endpoint/) is available on Github.
+++

## Services

### Order Poll

When sent a "spree:order:poll" message to /orders/poller, the endpoint fetches new orders from Spree.

####Request

```
{
  "store_name": "ABC Widgets",
  "message": "spree:order:poll",
  "created_at": "2013-09-26T20:26:17Z",
  "completed_at": "2013-09-26T20:26:24Z",
  "consumer_class": "Augury::Consumers::Remote",
  "attempt_at": "2013-09-26T20:26:20Z",
  "attempts": 0,
  "mapping": {
    "enabled": true,
    "filters": [ ],
    "identifiers": { },
    "messages": [
      "spree:order:poll"
    ],
    "name": "spree.order_poll",
    "options": {
      "retries_allowed": true
    },
    "parameters": [ ],
    "required": true,
    "store_id": {
      "$oid": "123"
    },
    "token": "abc123",
    "url": "http://ep-spree.spree.fm/orders/poller",
    "usage": {
      "1hr": 6,
      "6hr": 36,
      "24hr": 144,
      "3d": 1937
    },
    "usage_updated_at": "2013-09-26T20:24:19Z",
    "consumer": "Augury::Consumers::Remote"
  },
  "source": "accepted"
}
```

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| order_poll.last_updated_at | Import all orders after this timestamp | 2013-09-24T19:50:00Z |
| order_poll.per_page | Number of orders to poll per page (max 50) | 10 |

#### Response

```
{
  "code": "200",
  "response": {
    "message_id": "5245b538b4395707ef0036f5",
    "parameters": [
      {
        "name": "spree.order_poll.last_updated_at",
        "value": "2013-09-27T15:57:28Z"
      }
    ],
    "messages": [
      ...
    ]
  }
}
```
### Order Lock

When sent an "order:ship" message to '/orders/lock', the endpoint Locks the order in a Spree store, preventing the admin from editing it.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response

~~~
TODO: fill in response
~~~

### Order Count on Hand

When sent an "stock:change" message to '/stock/change', the endpoint updates the count on hand for a product in a Spree store.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| stock_location_id | ID of Stock Location in Spree | 2 |

#### Response

~~~
TODO: fill in response
~~~

### Order Import

When sent an "order:import" message to '/orders/import', the endpoint imports an order into the Spree store.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| truncate_address_address1 | Maximum Length of Address1 Field | 255 |

#### Response

~~~
TODO: fill in response
~~~

### Payments Capture

When sent an "order:capture" message to '/payments/capturer', the endpoint captures the payment on an order.

####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response

~~~
TODO: fill in response
~~~

### Inventory Unit Service

When sent an "shipment:confirm" message to /shipments/inventory_unit, the endpoint logs serial numbers on an inventory unit based on the external_ref provided.

####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response<commit_msg>More spree endpoint filled in<commit_after>---
title: Spree Endpoint
---

## Overview

The Spree endpoint is the endpoint that handles all the interaction between the hub and Spree stores. It provides a variety of actions for monitoring different entities, which will be described below.

+++
The source code for the [Spree Endpoint](https://github.com/spree/spree_endpoint/) is available on Github.
+++

## Services

### Order Poll

When sent a "spree:order:poll" message to /orders/poller, the endpoint fetches new orders from Spree.

####Request

```
{
  "store_name": "ABC Widgets",
  "message": "spree:order:poll",
  "created_at": "2013-09-26T20:26:17Z",
  "completed_at": "2013-09-26T20:26:24Z",
  "consumer_class": "Augury::Consumers::Remote",
  "attempt_at": "2013-09-26T20:26:20Z",
  "attempts": 0,
  "mapping": {
    "enabled": true,
    "filters": [ ],
    "identifiers": { },
    "messages": [
      "spree:order:poll"
    ],
    "name": "spree.order_poll",
    "options": {
      "retries_allowed": true
    },
    "parameters": [ ],
    "required": true,
    "store_id": {
      "$oid": "123"
    },
    "token": "abc123",
    "url": "http://ep-spree.spree.fm/orders/poller",
    "usage": {
      "1hr": 6,
      "6hr": 36,
      "24hr": 144,
      "3d": 1937
    },
    "usage_updated_at": "2013-09-26T20:24:19Z",
    "consumer": "Augury::Consumers::Remote"
  },
  "source": "accepted"
}
```

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| order_poll.last_updated_at | Import all orders after this timestamp | 2013-09-24T19:50:00Z |
| order_poll.per_page | Number of orders to poll per page (max 50) | 10 |

#### Response

```
{
  "code": "200",
  "response": {
    "message_id": "5245b538b4395707ef0036f5",
    "parameters": [
      {
        "name": "spree.order_poll.last_updated_at",
        "value": "2013-09-27T15:57:28Z"
      }
    ],
    "messages": [
      ...
    ]
  }
}
```
### Order Lock

When sent an "order:ship" message to '/orders/lock', the endpoint Locks the order in a Spree store, preventing the admin from editing it.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response

~~~
TODO: fill in response
~~~

### Order Count on Hand

When sent an "stock:change" message to '/stock/change', the endpoint updates the count on hand for a product in a Spree store.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| stock_location_id | ID of Stock Location in Spree | 2 |

#### Response

~~~
TODO: fill in response
~~~

### Order Import

When sent an "order:import" message to '/orders/import', the endpoint imports an order into the Spree store.


####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |
| truncate_address_address1 | Maximum Length of Address1 Field | 255 |

#### Response

~~~
TODO: fill in response
~~~

### Payments Capture

When sent an "order:capture" message to '/payments/capturer', the endpoint captures the payment on an order.

####Request

~~~
TODO: fill in request
~~~

#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response

~~~
TODO: fill in response
~~~

### Inventory Unit Service

When sent an "shipment:confirm" message to /shipments/inventory_unit, the endpoint logs serial numbers on an inventory unit based on the external_ref provided.

####Request

```json
{
  "message": "shipment:confirm",
  "message_id": "518726r84910000004",
  "payload": {
    "shipment_number": 1,
    "tracking_number": "123456",
    "tracking_url": "http://www.ups.com/WebTracking/track",
    "carrier": "UPS",
    "shipped_date": "2013-06-27T13:29:46Z",
    ...
  }
}
```


#### Parameters

| Name | Value | Example |
| :----| :-----| :------ |
| api_url | Your Spree Store's API URL | http://demostore.com/api/ |
| api_key | API Key for an Admin User | <KEY> |
| api_version | Spree Store Version | 2.0 |

#### Response
{'fraction_non_alphanumeric': 0.17938605840972074, 'fraction_numerical': 0.03602643359624814, 'mean_word_length': 3.1063457330415756, 'pattern_counts': {'":': 80, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4150736', 'n_tokens_mistral': 3479, 'n_tokens_neox': 3187, 'n_words': 939}