Search by

lasselehtinen / mockingbird-api-client

lasleh

This package is abandoned and no longer maintained. The author suggests using the wernersoderstrom/mockingbird-api-client package instead.

This is a client for Mockingbird external API

Package info

github.com/wernersoderstrom/mockingbird-api-client

pkg:composer/lasselehtinen/mockingbird-api-client

Fund package maintenance!

lasselehtinen

Statistics

Installs: 365

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.5.0 2026-12-01 22:08 UTC

This package is auto-updated.

Last update: 2026-12-02 10:26:22 UTC


README

Latest Version on Packagist run-tests Total Downloads

Mockingbird External API Client

A Laravel API client for Mockingbird that provides OAuth authentication, strongly typed DTOs powered by Spatie Laravel Data, and convenient service classes for accessing editions, contributors, assets and other Mockingbird resources.

Installation

You can install the package via composer:

composer require wernersoderstrom/mockingbird-api-client

You can publish the config file with:

php artisan vendor:publish --tag="mockingbird-api-client-config"

This is the contents of the published config file:

return [
    'base_url' => env('MOCKINGBIRD_BASE_URL', 'https://tenantname-external-api-app.azurewebsites.net'),
    'oauth_url' => env('MOCKINGBIRD_OAUTH_URL', 'https://auth.mockingbird.nu/core/token'),
    'client_id' => env('MOCKINGBIRD_CLIENT_ID', 'client_name_here'),
    'client_secret' => env('MOCKINGBIRD_CLIENT_SECRET', 'client_secret_here'),
    'username' => env('MOCKINGBIRD_USERNAME', 'firstname.lastname@tenant.com'),
    'password' => env('MOCKINGBIRD_PASSWORD', 'mockingbird_user_password_here'),
    'scope' => env('MOCKINGBIRD_SCOPE', 'opus mockingbird'),
];

Usage

The package exposes dedicated services for each API area.

Edition

use Wernersoderstrom\MockingbirdApiClient\Editions\EditionService;

$edition = app(EditionService::class);
$edition = $edition->get('1ca73850-96c2-4ac3-8b98-44d35c9378d1');

Or through dependency injection:

use Wernersoderstrom\MockingbirdApiClient\Editions\EditionService;

final class EditionController
{
    public function __construct(
        private readonly EditionService $edition,
    ) {}

    public function show(string $id)
    {
        return $this->edition->get($id);
    }
}

The service is registered as a singleton and can be resolved from Laravel's service container.

All editions can be listed with all(). The editions are fetched a page at a time as the collection is iterated:

use Wernersoderstrom\MockingbirdApiClient\Editions\EditionService;
use Wernersoderstrom\MockingbirdApiClient\Editions\EditionSummaryData;

app(EditionService::class)->all()->each(function (EditionSummaryData $edition) {
    // $edition->gtin, $edition->title, $edition->publishingHouse
});

Contact

use Wernersoderstrom\MockingbirdApiClient\Contacts\ContactService;

$contact = app(ContactService::class)->get($contributor->contactIdLegacy);
$contact->isCompany();

Data objects

Generated by composer docs from the DTO classes, with example values from the public edition in tests/Fixtures/edition.json. Do not edit by hand.

EditionData

Property Type Example Description
id string 1ca73850-96c2-4ac3-8b98-44d35c9378d1 From productId. Mockingbird product ID
legacyId int 244940 From editionIdLegacy
legacyWorkId int 244939 From workIdLegacy
title string Murtuneet mielet
subtitle ?string Taistelu suomalaissotilaiden hermoista 1939-1945
originalTitle ?string null
gtin ?int 9789510374665 From ean. EAN-13 / ISBN-13
publishingHouseId ?string wsoy From publishingHouse.id. Mockingbird publishing house, e.g. wsoy
publishingHouse string WSOY From publishingHouse.name
brand ?string WSOY From brand.name
bindingCode BindingCodeData BindingCodeData
isDigital bool false
contributors DataCollection<int, ContributorData> list of ContributorData
serie ?string null From serie.name
marketingSerie ?string null null when empty in Mockingbird
costCenter ?CostCenterData CostCenterData
season ?SeasonData SeasonData
governingCode string Sold out From governingCode.name
awards DataCollection<int, AwardData> list of AwardData
keywords array<int, string> ["traumat","ENNAKKOTIETO","sotahistoria"]
bookTypes array<int, string> []
libraryCode ?LibraryCodeData LibraryCodeData
mainGroup ?MainGroupData MainGroupData
subGroup ?SubGroupData SubGroupData From subgroup
depth ?float 37 From measurements.depth. null when 0 in Mockingbird
height ?float 218 From measurements.height. null when 0 in Mockingbird
weight ?float 0.615 From measurements.weight. null when 0 in Mockingbird
width ?float 140 From measurements.width. null when 0 in Mockingbird
languages DataCollection<int, LanguageData> list of LanguageData
originalLanguages DataCollection<int, LanguageData> []
pages ?int 475 null when 0 in Mockingbird
estimatedPages ?int null From mediaLength.estimatedPages. null when 0 in Mockingbird
durationInSeconds ?int null From mediaLength.durationInSeconds. Length of audio products. null when 0 in Mockingbird
characters ?int null From mediaLength.characters. Length of e-books in characters. null when 0 in Mockingbird
prices DataCollection<int, PriceData> list of PriceData
pocketBookPriceGroup ?string null From priceGroupPocket.name. Price group of pocket books, e.g. G
textAndDataMiningProhibited bool false From prohibitTextAndDataMining
publishingDate ?Carbon 2013-08-15T00:00:00+00:00
rightsPeriodStart ?Carbon 2010-06-21T00:00:00+00:00 From rightsPeriod.start. Start of the publishing rights period
rightsPeriodEnd ?Carbon null From rightsPeriod.end. End of the publishing rights period, null when open-ended
activeWebPeriodStart ?Carbon null From activeWebPeriod.startDate. Start of the period the product is shown in web shops
activeWebPeriodEnd ?Carbon null From activeWebPeriod.endDate. End of the period the product is shown in web shops, null when open-ended
stockBalance ?int 0
technicalProductionTypeName ?string BBF Generic
vatRate float 0.135 From vat. VAT as a fraction, e.g. 0.135 for 13.5 %
texts DataCollection<int, TextData> list of TextData Marketing texts as HTML, empty texts removed
dispositionCode string d From dispositionCode.name
links DataCollection<int, LinkData> list of LinkData E.g. reading samples, links without a URL removed
battery ?BatteryData null null when the product has no batteries
print ?PrintData PrintData Current print from v2/EditionByIsbn/{gtin}/Print. null when the edition has no prints
webKeywords array<int, string> ["traumat","Tieto-Finlandia-palkinto","ENNAKKOTIETO"] Keywords for web shops
isMainEdition bool true Computed. This edition is the work's main edition
isWebEdition bool true Computed. This edition is the work's web edition
isTranslated bool false Computed. Has a contributor whose role contains "Translator"
imprint ?string null Computed. The brand, unless it is Johnny Kniga or the same as the publishing house
targetGroups array [] Computed. Target groups from the work's communication plan, e.g. Tapalukijat
firstPublishedYear ?int null Computed. Year the work was first published, e.g. the original of a translation. From the work's firstPublishedYear
internalTitle ?string Murtuneet mielet kirja Computed. Title shortened so that it and the format suffix (e.g. kirja, e-kirja) fit in 50 characters
Method Description
printer(): ?ContributorData The printer contributor, excluding "Yhteispainatus". null for digital products.
calculatedPublisherRetailPrice(): ?PriceData Retail price calculated from the reseller price including VAT. Pocket books, manga and digital products are rounded up to the next 10 cents, everything else to the next .90.
retailPriceMultiplier(): float Multiplier from the reseller price including VAT to the retail price.
mainEditionCostCenter(): ?CostCenterData Cost center of the work.
mainEditionGtin(): ?int GTIN of the work's main edition.

BindingCodeData

Property Type Example Description
id string BB
name string Hardback
onixCodelistValue string BB ONIX product form code (List 150), mapped from id

ContributorData

Property Type Example Description
contactIdLegacy int 55001
contactId string 00000000-0000-0000-0000-000000000000
firstName string Ville
lastName ?string Kivimäki
role ContributorRoleData ContributorRoleData
prioLevel ?string Primary From prioLevel.name. Primary, Secondary or Internal
sortOrder ?int 0 Position of the contributor in the edition, starting from 0
fullName string Ville Kivimäki Computed. First and last name joined with a space

ContributorRoleData

Property Type Example Description
id int 304 Sent as a numeric string by the API
name string Author
onixCodelistValue ?string A01 ONIX contributor role code (List 17), mapped from name. null when there is no mapping

CostCenterData

Property Type Example Description
id int 313 From code
name string WSOY - Tietokirjat

SeasonData

Property Type Example Description
year ?int 2013 null when the period is N/A
period ?string Autumn Spring, Autumn or a number. null when N/A
name ?string 2013/2 Computed. 2026/1 for spring, 2026/2 for autumn, null without a year

PriceData

Property Type Example Description
currency string EUR From price.currency
value float 41.32 From price.value
type string PublisherRetailPrice From priceType
onixCodelistValue ?string 41 ONIX price type code (List 58), mapped from priceType. null when there is no mapping

LanguageData

Property Type Example Description
iso639LanguageCode string fin From code. ISO 639-2/B code, e.g. fin
name string Finnish

MainGroupData

Property Type Example Description
id int 7 From erpId
name string Tietokirjallisuus

SubGroupData

Property Type Example Description
id int 4 From erpId
name string Historia

AwardData

Property Type Example Description
name string Tieto-Finlandia-palkinto

TextData

Property Type Example Description
text string Aseiden vaiettua moni veteraani heräsi öisiin painajaisiinsa... HTML
typeId ?int 1 From textTypeId. Mockingbird text type, e.g. 1 for Copy 1 and 19 for Headline

LinkData

Property Type Example Description
name string Reading sample E.g. Reading sample
url string https://elvis.bonnierbooks.fi/file/Et49NFxAK5fBQlOu9UArfI/*/...
isWebsite bool false
isBlog bool false

LibraryCodeData

Property Type Example Description
id ?string 92.73 Finnish public library classification (YKL) code, e.g. 84.2
prefixId ?string null Prefix of the code, e.g. L or N

PrintData

Property Type Example Description
printNumber int 5
interior ?InteriorData InteriorData
case ?CoverData CoverData From covers.case. Hardback case
dustJacket ?CoverData CoverData From covers.dustJacket
printedCase ?CoverData CoverData From covers.printedCase. Printed hardback case
softCover ?CoverData CoverData From covers.softCover
endpapers ?EndpapersData EndpapersData
imageSheet ?ImageSheetData ImageSheetData
bookbinding ?BookbindingData BookbindingData
ebookVersion ?string null From ebook.version. ePub version, e.g. 2.0 or 3.0
ebookHasAudioFile bool false From ebook.hasAudioFile. The e-book contains audio

InteriorData

Property Type Example Description
paperName ?string ECR70_18 From name. E.g. HOLMEN Book Cream, FSC
paperType ?string null From paper.name. E.g. Wood-containing (text)
paperWeight ?string 70 From weight.name. Grammage, e.g. 70, or Other when given in paperWeightCustomValue
paperWeightCustomValue ?float null From weight.customValue
paperBulk ?string Other From bulk.name. E.g. 2.0, or Other when given in paperBulkCustomValue
paperBulkCustomValue ?float 1.8 From bulk.customValue
printing ?string 1+1 From printing.name. E.g. 1+1
colors ?string ``
trimmedFormatWidth ?int 134 From trimmedFormat.width. In millimetres. null when 0 in Mockingbird
trimmedFormatHeight ?int 213 From trimmedFormat.height. In millimetres. null when 0 in Mockingbird

CoverData

Property Type Example Description
material ?string null Case material, e.g. GEL-LS-191 black
paperType ?string Other From paper.name. E.g. Wood-free coated or Other
paperName ?string COAGLO130 From paper.customName. Custom paper name, e.g. ARTG130
paperWeight ?int null Grammage. null when 0 in Mockingbird
printing ?string 4+0 From printing.name. E.g. 4+0
colors ?string null
lamination ?string Matt lamination From lamination.name
foil ?string Kurz Luxor 428 E.g. Kurz Luxor 220 gold
foilPlacement ?string null From placement.name. E.g. Spine
hasBlindEmbossing bool false
hasDispersionVarnish bool false
hasReliefSpotVarnish bool false
hasUvSpotVarnishGlossy bool false
hasUvSpotVarnishMatt bool false

EndpapersData

Property Type Example Description
paperType ?string null From paper.name. E.g. Wood-free book paper
paperWeight ?int 115 From weight. Grammage. null when 0 in Mockingbird
printing ?string null From printing.name. E.g. 0+0
colors ?string 0+0
isSelfEnded bool false

ImageSheetData

Property Type Example Description
paperName ?string GPR115 From name. E.g. G-Print
paperType ?string null From paper.name. E.g. Wood-free coated
paperWeight ?int 115 From weight. Grammage. null when 0 in Mockingbird
printing ?string 1+1 From printing.name. E.g. 4+4
pages ?int null

BookbindingData

Property Type Example Description
binding ?string null From binding.name. E.g. Glued binding
boardThickness ?string null From boardThickness.name. In millimetres, e.g. 2.0
headband ?string 160036 (Tumman sinivalkoinen)
ribbonMarker ?string null Ribbon bookmark
spineType ?string null From spineType.name. E.g. Rounded
spineWidth ?int null In millimetres
comment ?string null

BatteryData

Property Type Example Description
description ?string 3 batteries included (AG10 x 3 button cell batteries (1.5V x... E.g. 3 batteries included (AG10 x 3 button cell batteries (1.5V x 3 = 4.5V)
chemistry ?string Zinc-Manganese dioxide From type.name. Battery chemistry, e.g. Zinc-Manganese dioxide
chemistryOnixCodelistValue ?string 26 From type.onixCode. ONIX battery chemistry code, e.g. 26

StockBalanceData

Property Type Example Description
gtin int 9789510374665 EAN-13 / ISBN-13 of the edition
balance int 10 New stock balance

EditionSummaryData

Property Type Example Description
id string 1ca73850-96c2-4ac3-8b98-44d35c9378d1 From productId. Mockingbird product ID
legacyId int 244940 From editionIdLegacy
gtin ?int 9789510374665 From ean. EAN-13 / ISBN-13, null when the edition has none
title string Murtuneet mielet
publishingHouse string WSOY From publishingHouse.name

ContactData

Property Type Example Description
id string 00000000-0000-0000-0000-000000000000 From contactId. Mockingbird contact ID
legacyId int 55001 From contactIdLegacy. Legacy contact ID, the same as ContributorData::$contactIdLegacy
type string Person From contactType. Person or Company
firstName ?string Ville
lastName ?string Kivimäki
Method Description
isCompany(): bool The contact is a company instead of a person

Example

$edition->toArray(), lists shortened to one item
{
    "isMainEdition": true,
    "isWebEdition": true,
    "isTranslated": false,
    "imprint": null,
    "targetGroups": [],
    "firstPublishedYear": null,
    "id": "1ca73850-96c2-4ac3-8b98-44d35c9378d1",
    "legacyId": 244940,
    "legacyWorkId": 244939,
    "title": "Murtuneet mielet",
    "subtitle": "Taistelu suomalaissotilaiden hermoista 1939-1945",
    "originalTitle": null,
    "gtin": 9789510374665,
    "publishingHouseId": "wsoy",
    "publishingHouse": "WSOY",
    "brand": "WSOY",
    "bindingCode": {
        "id": "BB",
        "name": "Hardback",
        "onixCodelistValue": "BB"
    },
    "isDigital": false,
    "contributors": [
        {
            "fullName": "Ville Kivimäki",
            "contactIdLegacy": 55001,
            "contactId": "00000000-0000-0000-0000-000000000000",
            "firstName": "Ville",
            "lastName": "Kivimäki",
            "role": {
                "id": 304,
                "name": "Author",
                "onixCodelistValue": "A01"
            },
            "prioLevel": "Primary",
            "sortOrder": 0
        }
    ],
    "serie": null,
    "marketingSerie": null,
    "costCenter": {
        "id": 313,
        "name": "WSOY - Tietokirjat"
    },
    "season": {
        "name": "2013/2",
        "year": 2013,
        "period": "Autumn"
    },
    "governingCode": "Sold out",
    "awards": [
        {
            "name": "Tieto-Finlandia-palkinto"
        }
    ],
    "keywords": [
        "traumat"
    ],
    "bookTypes": [],
    "libraryCode": {
        "id": "92.73",
        "prefixId": null
    },
    "mainGroup": {
        "id": 7,
        "name": "Tietokirjallisuus"
    },
    "subGroup": {
        "id": 4,
        "name": "Historia"
    },
    "depth": 37,
    "height": 218,
    "weight": 0.615,
    "width": 140,
    "languages": [
        {
            "iso639LanguageCode": "fin",
            "name": "Finnish"
        }
    ],
    "originalLanguages": [],
    "pages": 475,
    "estimatedPages": null,
    "durationInSeconds": null,
    "characters": null,
    "prices": [
        {
            "currency": "EUR",
            "value": 41.32,
            "type": "PublisherRetailPrice",
            "onixCodelistValue": "41"
        }
    ],
    "pocketBookPriceGroup": null,
    "textAndDataMiningProhibited": false,
    "publishingDate": "2013-08-15T00:00:00+00:00",
    "rightsPeriodStart": "2010-06-21T00:00:00+00:00",
    "rightsPeriodEnd": null,
    "activeWebPeriodStart": null,
    "activeWebPeriodEnd": null,
    "stockBalance": 0,
    "technicalProductionTypeName": "BBF Generic",
    "vatRate": 0.135,
    "texts": [
        {
            "text": "<p>Aseiden vaiettua moni veteraani heräsi öisiin painajaisiinsa. Mitä he olivat...",
            "typeId": 1
        }
    ],
    "internalTitle": "Murtuneet mielet kirja",
    "dispositionCode": "d",
    "links": [
        {
            "name": "Reading sample",
            "url": "https://elvis.bonnierbooks.fi/file/Et49NFxAK5fBQlOu9UArfI/*/9789510374665_lukun....",
            "isWebsite": false,
            "isBlog": false
        }
    ],
    "battery": null,
    "print": {
        "printNumber": 5,
        "interior": {
            "paperName": "ECR70_18",
            "paperType": null,
            "paperWeight": "70",
            "paperWeightCustomValue": null,
            "paperBulk": "Other",
            "paperBulkCustomValue": 1.8,
            "printing": "1+1",
            "colors": "",
            "trimmedFormatWidth": 134,
            "trimmedFormatHeight": 213
        },
        "case": {
            "material": "GX-156-LS (Harmaan sininen) + folio 932 (Harmaa)",
            "paperType": null,
            "paperName": null,
            "paperWeight": null,
            "printing": null,
            "colors": null,
            "lamination": null,
            "foil": null,
            "foilPlacement": null,
            "hasBlindEmbossing": false,
            "hasDispersionVarnish": false,
            "hasReliefSpotVarnish": false,
            "hasUvSpotVarnishGlossy": false,
            "hasUvSpotVarnishMatt": false
        },
        "dustJacket": {
            "material": null,
            "paperType": "Other",
            "paperName": "COAGLO130",
            "paperWeight": null,
            "printing": "4+0",
            "colors": null,
            "lamination": "Matt lamination",
            "foil": "Kurz Luxor 428",
            "foilPlacement": null,
            "hasBlindEmbossing": false,
            "hasDispersionVarnish": false,
            "hasReliefSpotVarnish": false,
            "hasUvSpotVarnishGlossy": false,
            "hasUvSpotVarnishMatt": false
        },
        "printedCase": {
            "material": null,
            "paperType": null,
            "paperName": null,
            "paperWeight": null,
            "printing": null,
            "colors": null,
            "lamination": null,
            "foil": null,
            "foilPlacement": null,
            "hasBlindEmbossing": false,
            "hasDispersionVarnish": false,
            "hasReliefSpotVarnish": false,
            "hasUvSpotVarnishGlossy": false,
            "hasUvSpotVarnishMatt": false
        },
        "softCover": {
            "material": null,
            "paperType": null,
            "paperName": null,
            "paperWeight": null,
            "printing": null,
            "colors": null,
            "lamination": null,
            "foil": null,
            "foilPlacement": null,
            "hasBlindEmbossing": false,
            "hasDispersionVarnish": false,
            "hasReliefSpotVarnish": false,
            "hasUvSpotVarnishGlossy": false,
            "hasUvSpotVarnishMatt": false
        },
        "endpapers": {
            "paperType": null,
            "paperWeight": 115,
            "printing": null,
            "colors": "0+0",
            "isSelfEnded": false
        },
        "imageSheet": {
            "paperName": "GPR115",
            "paperType": null,
            "paperWeight": 115,
            "printing": "1+1",
            "pages": null
        },
        "bookbinding": {
            "binding": null,
            "boardThickness": null,
            "headband": "160036 (Tumman sinivalkoinen)",
            "ribbonMarker": null,
            "spineType": null,
            "spineWidth": null,
            "comment": null
        },
        "ebookVersion": null,
        "ebookHasAudioFile": false
    },
    "webKeywords": [
        "traumat"
    ]
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.