/** * @covers Moneybird\ApiConnector::requestsLeft */ public function testRequestsLeft() { include './config.php'; $transport = getTransport($config); $mapper = new XmlMapper(); try { $this->object = new ApiConnector($config['clientname'], $transport, $mapper); $this->assertGreaterThan(0, $this->object->requestsLeft()); } catch (ForBiddenException $e) { } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { include 'config.php'; $transport = getTransport($config); $mapper = new XmlMapper(); $this->apiConnector = new ApiConnector($config['clientname'], $transport, $mapper); $this->service = $this->apiConnector->getService('Invoice'); if (!is_null(self::$invoiceId)) { $this->object = $this->service->getById(self::$invoiceId); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { if (file_exists('../config.php')) { include '../config.php'; } else { include 'config.php'; } $transport = getTransport($config); $mapper = new XmlMapper(); $connector = new ApiConnector($config['clientname'], $transport, $mapper); $this->object = $connector->getService('Product'); }
/** * @param string $sender * @param string $message * @param array $receivers * @return mixed|null */ public function sendMessage($sender, $message, array $receivers) { if (!is_string($sender)) { throw new \InvalidArgumentException(sprintf('Sender has to be a string, got "%s"', gettype($sender)), self::ERROR_SEND_MESSAGE_INVALID_SENDER); } $receivers = array_diff(array_unique(array_map('trim', $receivers)), ['']); if (!count($receivers)) { throw new \InvalidArgumentException('Define at least one receiver.', self::ERROR_SEND_MESSAGE_NO_RECEIVERS); } $data = ['receivers' => $receivers, 'message' => is_string($message) ? $message : json_encode($message), 'sender' => $sender]; return $this->apiConnector->getData('send-message', $data); }
/** * Send command to API * @param $action * @return mixed */ private function connectTo($action) { $uri = DigitalOcean::API_URL . '/' . $action; $uri .= strpos($uri, '?') !== false ? '&' : '?'; $uri .= 'client_id=' . $this->clientId . '&api_key=' . $this->apiKey; return json_decode($this->apiConnector->connectToApi($uri)); }
/** * @covers Moneybird\Contact::getIncomingInvoices */ public function testGetIncomingInvoices() { $invoices = $this->object->getIncomingInvoices($this->apiConnector->getService('IncomingInvoice')); $this->assertGreaterThan(0, count($invoices), 'No invoices found'); foreach ($invoices as $invoice) { $this->assertEquals(self::$contactId, $invoice->contactId); $invoice->delete($this->apiConnector->getService('IncomingInvoice')); } }
/** * @coversNothing */ public function testToXmlRecurringTemplate() { $details = new \Subclass_RecurringTemplate_Detail_Array(); $details->append(new \Subclass_RecurringTemplate_Detail(array('amount' => 5, 'description' => 'My template line', 'price' => 20, 'taxRateId' => self::$taxRateId))); $details->append(new \Subclass_RecurringTemplate_Detail(array('amount' => 1, 'description' => 'My second template line', 'price' => 12, 'taxRateId' => self::$taxRateId))); $template = new \SubclassRecurringTemplate(array('poNumber' => 'PO Number', 'details' => $details, 'frequencyType' => RecurringTemplate::FREQUENCY_YEAR), self::$contact); $template->save($this->apiConnector->getService('RecurringTemplate')); $this->assertInstanceOf('Moneybird\\RecurringTemplate', $template); $this->assertInstanceOf('\\SubclassRecurringTemplate', $template); $this->assertNotNull($template->id); $this->assertGreaterThan(0, $template->id); }
/** * Get all tax rates * * @param string $filter Filter name (all, sales, purchase, inactive) * @return TaxRate_Array * @throws InvalidFilterException */ public function getAll($filter = null) { $filters = array('all', 'sales', 'purchase', 'inactive'); if (!in_array($filter, $filters)) { $message = 'Unknown filter "' . $filter . '" for TaxRates'; $message .= '; available filters: ' . implode(', ', $filters); throw new InvalidFilterException($message); } $rates = new TaxRate_Array(); foreach ($this->connector->getAll('TaxRate') as $rate) { if ($filter == 'inactive' && $rate->active || $filter != 'inactive' && !$rate->active) { continue; } if ($filter == 'sales' && $rate->taxRateType != TaxRate::RATE_TYPE_SALES) { continue; } elseif ($filter == 'purchase' && $rate->taxRateType != TaxRate::RATE_TYPE_PURCHASE) { continue; } $rates->append($rate); } return $rates; }
public function getAll() { return $this->connector->getAll('Product'); }
/** * Deletes a contact * @param Contact $contact * @return self */ public function delete(Contact $contact) { $this->connector->delete($contact); return $this; }
/** * Get the raw PDF content * @param Estimate $estimate * @return string */ public function getPdf(Estimate $estimate) { return $this->connector->getPdf($estimate); }
/** * Get the raw PDF content * @param Invoice $invoice * @return string */ public function getPdf(Invoice $invoice) { return $this->connector->getPdf($invoice); }
public function getAll() { return $this->connector->getAll('InvoiceProfile'); }
/** * Register a payment for the invoice * @param IncomingInvoice $invoice * @param IncomingInvoice_Payment $payment * @return IncomingInvoice */ public function registerPayment(IncomingInvoice &$invoice, IncomingInvoice_Payment $payment) { return $this->connector->registerPayment($invoice, $payment); }
/** * Deletes a template * @param RecurringTemplate $template * @return self */ public function delete(RecurringTemplate $template) { $this->connector->delete($template); return $this; }