Code Monkey home page Code Monkey logo

finn-transfer-sdk's Introduction

finn-transfer-sdk

Test

SDK for transferring ads to finn.no

You need an agreement to use this API, and the complete documentation can be found here.

This library implements the REST API part described in that documentation.

Installation

composer require eiriksm/finn-transfer-sdk

Usage

<?php

use eiriksm\FinnTransfer\AdTypes\TractorXml;
use eiriksm\FinnTransfer\FinnTransfer;
use GuzzleHttp\Client;

$partner_id = 'mypartnerid';
$provider = 'myprovider';
// Start by constructing an ad type. For example a tractor ad.
$ad = new TractorXml($partner_id, $provider);
// Then set some properties. We probably want to set an ad title, and a price,
// for example.
$ad->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);

finn-transfer-sdk's People

Contributors

eiriksm avatar ivanruzak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.