Skip to content

Commit afa06b7

Browse files
committed
Merge pull request #10 from spree-contrib/serializer-parent
Be able to set serializer parent and remove sponsor
2 parents ef9b7f7 + beda14f commit afa06b7

23 files changed

+96
-75
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 0.2.2
4+
5+
* The parent serializer for `Spree::BaseSerializer` is now configurable.
6+
In some instances, you may have an `ApplicationSerializer`.
7+
To make the `Spree::BaseSerializer` use an `ApplicationSerializer` instead
8+
of the `ActiveModel::Serializer`:
9+
10+
```ruby
11+
# config/initializers/spree_api_v2.rb; or
12+
# config/initializers/solidus_api_v2.rb
13+
SpreeApiV2.setup do |config|
14+
config.parent_serializer = ApplicationSerializer
15+
end
16+
317
## 0.2.1
418

519
* Fixes a bug where the user serializer wasn't extending from the `Spree::BaseSerializer` this is now fixed.

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,4 @@ bundle exec rake GEMNAME=spree_api_v2
9191
bundle exec rake GEMNAME=solidus_api_v2
9292
```
9393

94-
## Sponsored by:
95-
96-
[![Kabuni](https://assets.kabuni.com/kabuni-secondary-logomark-xlarge.png)](https://kabuni.com?utm_source=SpreeApiV2&utm_medium=sponsor&utm_campaign=opensource)
97-
9894
Copyright © 2015 Ben A. Morgan, released under the New BSD License

app/serializers/spree/base_serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Spree
2-
class BaseSerializer < ActiveModel::Serializer
2+
class BaseSerializer < SpreeApiV2.parent_serializer
33
def image_links(object)
44
{
55
original: object.url(:original),

docs/source/includes/_authentication.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```shell
44
# Specifying the token as a header.
5-
curl "https://kabuni.com/api/v1/endpoint"
5+
curl "https://example.com/api/v1/endpoint"
66
-H "X-Spree-Token: abc123"
77

88
# Specifying the token as a param.
@@ -20,7 +20,7 @@ Spree does not expect every request to require an API key (such as reading publi
2020
## Authenticate a User (Login)
2121

2222
```shell
23-
curl "https://kabuni.com/api/v1/account/signin"
23+
curl "https://example.com/api/v1/account/signin"
2424
-X POST
2525
-d user[email][email protected]
2626
-d user[password]=spree123

docs/source/includes/_countries.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## List Countries
44

55
```shell
6-
curl "https://kabuni.com/api/v2/countries"
6+
curl "https://example.com/api/v2/countries"
77
```
88

99
```json
@@ -40,7 +40,7 @@ List all of the ~200 countries in the DB.
4040
## Show Country
4141

4242
```shell
43-
curl "https://kabuni.com/api/v2/countries/1"
43+
curl "https://example.com/api/v2/countries/1"
4444
```
4545

4646
```json
@@ -75,7 +75,7 @@ Select a country via its `id`.
7575
## List States of a Country
7676

7777
```shell
78-
curl "https://kabuni.com/api/v2/countries/1/states"
78+
curl "https://example.com/api/v2/countries/1/states"
7979
```
8080

8181
```json
@@ -106,7 +106,7 @@ See all of the states that a country owns via the country's `id`.
106106
## Show State of a Country
107107

108108
```shell
109-
curl "https://kabuni.com/api/v2/countries/1/states/1"
109+
curl "https://example.com/api/v2/countries/1/states/1"
110110
```
111111

112112
```json

docs/source/includes/_filtering.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Filtering
22

33
```shell
4-
curl "https://kabuni.com/api/v2/kittens?filter[id]=1"
5-
curl "https://kabuni.com/api/v2/kittens?filter[id]=2,3,4"
6-
curl "https://kabuni.com/api/v2/kittens?filter[breed]=Persian,British%20Shorthair,Bengal"
4+
curl "https://example.com/api/v2/kittens?filter[id]=1"
5+
curl "https://example.com/api/v2/kittens?filter[id]=2,3,4"
6+
curl "https://example.com/api/v2/kittens?filter[breed]=Persian,British%20Shorthair,Bengal"
77
```
88

99
This project supports the [JSON API's `filter` keyword](http://jsonapi.org/format/#fetching-filtering) with only the root object, not any of its relationships yet.

docs/source/includes/_images.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## List Images
44

55
```shell
6-
curl "https://kabuni.com/api/v2/images"
6+
curl "https://example.com/api/v2/images"
77
```
88

99
```json
@@ -41,7 +41,7 @@ List all of the images stored in the database.
4141
## Show Image
4242

4343
```shell
44-
curl "https://kabuni.com/api/v2/images/1"
44+
curl "https://example.com/api/v2/images/1"
4545
```
4646

4747
```json
@@ -77,7 +77,7 @@ Fetch an image and its links via the image's `id`.
7777
## Show Variant of an Image
7878

7979
```shell
80-
curl "https://kabuni.com/api/v2/images/1/variant"
80+
curl "https://example.com/api/v2/images/1/variant"
8181
```
8282

8383
```json
@@ -138,7 +138,7 @@ Fetch the variant that an image belongs to via the variant's `id`.
138138
## Show Product of an Image
139139

140140
```shell
141-
curl "https://kabuni.com/api/v2/images/1/product"
141+
curl "https://example.com/api/v2/images/1/product"
142142
```
143143

144144
```json

docs/source/includes/_line_items.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Create Line Item
44

55
```shell
6-
curl "https://kabuni.com/api/v2/line_items"
6+
curl "https://example.com/api/v2/line_items"
77
-X POST
88
-d token=abc123
99
-d line_item[order_id]=1
@@ -53,7 +53,7 @@ This endpoint allows you add a variant to a users order by creating a line item.
5353
> Quantity is out of range.
5454
5555
```shell
56-
curl "https://kabuni.com/api/v2/line_items"
56+
curl "https://example.com/api/v2/line_items"
5757
-X POST
5858
-d token=abc123
5959
-d line_item[order_id]=1
@@ -80,7 +80,7 @@ When requesting an insanely large amount of variants to be added to your order,
8080
> Order could not be found.
8181
8282
```shell
83-
curl "https://kabuni.com/api/v2/line_items"
83+
curl "https://example.com/api/v2/line_items"
8484
-X POST
8585
-d token=abc123
8686
-d line_item[order_id]=0
@@ -108,7 +108,7 @@ When this happens, you'll receive an error because of it.
108108
> Product is out of stock.
109109
110110
```shell
111-
curl "https://kabuni.com/api/v2/line_items"
111+
curl "https://example.com/api/v2/line_items"
112112
-X POST
113113
-d token=abc123
114114
-d line_item[order_id]=1

docs/source/includes/_option_types.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## List Option Types
44

55
```shell
6-
curl "https://kabuni.com/api/v2/option_types"
6+
curl "https://example.com/api/v2/option_types"
77
```
88

99
```json
@@ -45,7 +45,7 @@ List all of the option types in the database.
4545
## Show Option Type
4646

4747
```shell
48-
curl "https://kabuni.com/api/v2/option_types/1"
48+
curl "https://example.com/api/v2/option_types/1"
4949
```
5050

5151
```json
@@ -85,7 +85,7 @@ Fetch an option type in the database.
8585
## List Option Values of a Option Type
8686

8787
```shell
88-
curl "https://kabuni.com/api/v2/option_types/1/option_values"
88+
curl "https://example.com/api/v2/option_types/1/option_values"
8989
```
9090

9191
```json
@@ -117,7 +117,7 @@ See all of the option values that an option type owns.
117117
## Show Option Values of a Option Type
118118

119119
```shell
120-
curl "https://kabuni.com/api/v2/option_types/1/option_values/1"
120+
curl "https://example.com/api/v2/option_types/1/option_values/1"
121121
```
122122

123123
```json
@@ -147,7 +147,7 @@ Fetch an option value that an option type owns.
147147
## List Products of a Option Type
148148

149149
```shell
150-
curl "https://kabuni.com/api/v2/option_types/1/products"
150+
curl "https://example.com/api/v2/option_types/1/products"
151151
```
152152

153153
```json
@@ -209,7 +209,7 @@ See all of the products that an option type owns.
209209
## Show Product of a Option Type
210210

211211
```shell
212-
curl "https://kabuni.com/api/v2/option_types/1/products/1"
212+
curl "https://example.com/api/v2/option_types/1/products/1"
213213
```
214214

215215
```json

docs/source/includes/_option_values.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## List Option Values
44

55
```shell
6-
curl "https://kabuni.com/api/v2/option_values"
6+
curl "https://example.com/api/v2/option_values"
77
```
88

99
```json
@@ -35,7 +35,7 @@ List all of the option values.
3535
## Show Option Value
3636

3737
```shell
38-
curl "https://kabuni.com/api/v2/option_values/1"
38+
curl "https://example.com/api/v2/option_values/1"
3939
```
4040

4141
```json
@@ -65,7 +65,7 @@ Find an option value by its `id`.
6565
## Show Option Type of an Option Value
6666

6767
```shell
68-
curl "https://kabuni.com/api/v2/option_values/1/option_type"
68+
curl "https://example.com/api/v2/option_values/1/option_type"
6969
```
7070

7171
```json
@@ -105,7 +105,7 @@ Find the option type of an option value by the option value's `id`.
105105
## List Variants of an Option Value
106106

107107
```shell
108-
curl "https://kabuni.com/api/v2/option_values/1/variants"
108+
curl "https://example.com/api/v2/option_values/1/variants"
109109
```
110110

111111
```json
@@ -168,7 +168,7 @@ List all of the variants that belong to an option value via the option value's `
168168
## Show Variant of an Option Value
169169

170170
```shell
171-
curl "https://kabuni.com/api/v2/option_values/1/variants/1"
171+
curl "https://example.com/api/v2/option_values/1/variants/1"
172172
```
173173

174174
```json

0 commit comments

Comments
 (0)