Skip to content

Commit b515961

Browse files
author
Artur Gajewski (fraktio)
committed
Merge branch '24-salesinvoice-additionals' of github.com:xi-project/xi-netvisor into 24-salesinvoice-additionals
2 parents c1834c0 + 2a71344 commit b515961

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

library/Xi/Netvisor/Config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ public function getLanguage()
114114
return $this->language;
115115
}
116116

117+
/**
118+
* @param string $language
119+
*/
120+
public function setLanguage($language)
121+
{
122+
$this->language = $language;
123+
}
124+
117125
/**
118126
* @return string
119127
*/

library/Xi/Netvisor/Netvisor.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ public static function build(Config $config)
8080

8181
/**
8282
* @param SalesInvoice $invoice
83+
* @param String $language
8384
* @return null|string
8485
*/
85-
public function sendInvoice(SalesInvoice $invoice)
86+
public function sendInvoice(SalesInvoice $invoice, $language = null)
8687
{
87-
return $this->requestWithBody($invoice, 'salesinvoice');
88+
return $this->requestWithBody($invoice, 'salesinvoice', array(), $language);
8889
}
8990

9091
/**
@@ -185,10 +186,11 @@ private function get($service, array $params = [])
185186
* @param Root $root
186187
* @param string $service
187188
* @param array $params
189+
* @param string $language
188190
* @return null|string
189191
* @throws NetvisorException
190192
*/
191-
public function requestWithBody(Root $root, $service, array $params = [])
193+
public function requestWithBody(Root $root, $service, array $params = [], $language = null)
192194
{
193195
if (!$this->config->isEnabled()) {
194196
return null;
@@ -200,6 +202,10 @@ public function requestWithBody(Root $root, $service, array $params = [])
200202
throw new NetvisorException('XML is not valid according to DTD');
201203
}
202204

205+
if ($language !== null) {
206+
$this->config->setLanguage($language);
207+
}
208+
203209
$request = new Request($this->client, $this->config);
204210

205211
return $request->post($this->processXml($xml), $service, $params);

tests/Xi/Netvisor/ConfigTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ public function getsGivenParams()
3232
$this->assertEquals($c->getOrganizationId(), 'organizationId');
3333
$this->assertEquals($c->getUserKey(), 'userKey');
3434
$this->assertEquals($c->getPartnerKey(), 'partnerKey');
35+
36+
$c->setLanguage('orcish');
37+
$this->assertEquals($c->getLanguage(), 'orcish');
3538
}
39+
3640
}

tests/Xi/Netvisor/NetvisorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function returnsNullIfNotEnabled()
7979
$netvisor = new Netvisor($this->client, $config, new Validate());
8080

8181
$this->assertNull(
82-
$netvisor->requestWithBody(new TestResource(), 'service')
82+
$netvisor->requestWithBody(new TestResource(), 'service', array(), null)
8383
);
8484
}
8585

@@ -90,7 +90,7 @@ public function throwsIfXmlIsNotValid()
9090
{
9191
$this->setExpectedException('Xi\Netvisor\Exception\NetvisorException', 'XML is not valid according to DTD');
9292

93-
$this->netvisor->requestWithBody(new TestResource(), 'service');
93+
$this->netvisor->requestWithBody(new TestResource(), 'service', array(), null);
9494
}
9595

9696
/**
@@ -108,7 +108,7 @@ public function requestsIfDtdValidationPasses()
108108
new Response('200', array(), 'lus')
109109
));
110110

111-
$this->assertEquals('lus', $this->netvisor->requestWithBody($resource, 'service'));
111+
$this->assertEquals('lus', $this->netvisor->requestWithBody($resource, 'service', array(), null));
112112
}
113113

114114
/**
@@ -152,6 +152,6 @@ public function processInvoiceToWorkWithNetvisor()
152152
{
153153
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<salesinvoicedate><![CDATA[2014-02-17]]></salesinvoicedate>";
154154

155-
$this->assertEquals('<salesinvoicedate>2014-02-17</salesinvoicedate>', $this->netvisor->processXml($xml));
155+
$this->assertEquals('<salesinvoicedate><![CDATA[2014-02-17]]></salesinvoicedate>', $this->netvisor->processXml($xml));
156156
}
157157
}

0 commit comments

Comments
 (0)