Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eiriksm/finn-transfer-sdk
SDK for transferring ads to finn
https://github.com/eiriksm/finn-transfer-sdk
composer-package php
Last synced: 2 months ago
JSON representation
SDK for transferring ads to finn
- Host: GitHub
- URL: https://github.com/eiriksm/finn-transfer-sdk
- Owner: eiriksm
- License: mit
- Created: 2018-03-26T15:35:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T11:28:51.000Z (8 months ago)
- Last Synced: 2024-05-02T06:05:50.738Z (8 months ago)
- Topics: composer-package, php
- Language: PHP
- Size: 75.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# finn-transfer-sdk
[![Test](https://github.com/eiriksm/finn-transfer-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/eiriksm/finn-transfer-sdk/actions/workflows/test.yml)SDK for transferring ads to finn.no
You need an agreement to use this API, and the [complete documentation can be found here](https://hjelpesenter.finn.no/hc/no/articles/303554-How-to-get-started-Import-Transfer-choices).
This library implements the REST API part described in that documentation.
## Installation
`composer require eiriksm/finn-transfer-sdk`
## Usage
```php
setHeading('Used tractor for sale');
$ad->setMotorPrice(10000);
// For this example, we will also set postcode, since that is required.
$ad->setZipCode(9300);
// And maybe something a bit more specific. It has a 200 horse power engine.
$ad->setEngineEffect(200);
// We can also set arbitrary properties that are defined in the DTD for this ad
// type. For tractor that would be http://www.iad.no/dtd/IADIF-tractor-21.dtd
// where we can see there is something called TRACTOR_EQUIPMENT for example. We
// can find a list of valid values at https://www.finn.no/finn/referencevalue?adType=TRACTOR&xmlCode=TRACTOR_EQUIPMENT
$ad->TRACTOR_EQUIPMENT = 'KOMPLETT_FRONTLASTER';
// Now, there is probably a whole lot more you want to set on the ad, but those
// were some examples. In the end, use this method to get the xml. This will
// also validate the XML according to the spec.
$xml = $ad->getXml();// Next step would be to send this XML to finn.no.
$transfer = new FinnTransfer();
$transfer->setAd($ad);
// By default we are working against the dev environment of finn.no, but use
// this method to do it live(tm).
$transfer->getClient()->setLiveMode();
// Then get a HTTP client somehow.
$http_client = new Client();
// Now transfer the ad.
$result_xml = $transfer->transfer($http_client);
```