Skip to content

Commit

Permalink
Added YandexYmlCurrency class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklan committed Feb 23, 2018
1 parent 82bfa53 commit ed98a51
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"issues": "https://www.drupal.org/project/issues/yandex_yml",
"source": "http://cgit.drupalcode.org/yandex_yml"
},
"require": { }
"require": {
"php": ">=5.6"
}
}
74 changes: 74 additions & 0 deletions src/YandexYml/Currency/YandexYmlCurrency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Drupal\yandex_yml\YandexYml\Currency;

/**
* Class YandexYmlCurrency.
*
* @see https://yandex.ru/support/webmaster/goods-prices/technical-requirements.html#concept3__currencies
*/
class YandexYmlCurrency {

/**
* Currency code available in YML file.
*
* @var string
* Currency code name.
*/
private $id;

/**
* Currency exchange rate for the unit.
*
* @var mixed
*/
private $rate;

/**
* Currency code name.
*
* @example RUR, RUB, USD, EUR< UAH, KZT
*
* @param string $id
*
* @return YandexYmlCurrency
*/
public function setId($id) {
$this->id = $id;
return $this;
}

/**
* @return int
*/
public function getId() {
return $this->id;
}

/**
* Exchange rate will apply for currency with rate = 1. The values can be:
* - int/bool: your exchange rate from store, f.e. 10, 23.98.
* - CBRF: exchange rate from Central Bank of Russian Federation.
* - NBU: exchange rate from National Bank of Ukraine.
* - NBK: exchange rate from National Bank of Kazakhstan.
* - СВ: exchange rate from bank which selected in Yandex interface.
*
* Only RUR, RUB, BYN, UAH and KZT can be set as default currency (rate = 1).
*
* @param mixed $rate
*
* @return YandexYmlCurrency
*/
public function setRate($rate) {
$this->rate = $rate;
return $this;
}

/**
* @return mixed
*/
public function getRate() {
return $this->rate;
}

}
17 changes: 17 additions & 0 deletions src/YandexYmlGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Drupal\yandex_yml;

/**
* Class YandexYmlGenerator.
*/
class YandexYmlGenerator implements YandexYmlGeneratorInterface {

/**
* Constructs a new YandexYmlGenerator object.
*/
public function __construct() {

}

}
11 changes: 11 additions & 0 deletions src/YandexYmlGeneratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Drupal\yandex_yml;

/**
* Interface YandexYmlGeneratorInterface.
*/
interface YandexYmlGeneratorInterface {


}
5 changes: 5 additions & 0 deletions yandex_yml.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
yandex_yml.generator:
class: Drupal\yandex_yml\YandexYmlGenerator
arguments: []

0 comments on commit ed98a51

Please sign in to comment.