Skip to content

Commit

Permalink
Readme (#32)
Browse files Browse the repository at this point in the history
* Readme file

* improve the readme file
  • Loading branch information
Ibrahimhizeoui authored and Nyholm committed Aug 27, 2017
1 parent 0854dcc commit b39fe35
Showing 1 changed file with 104 additions and 18 deletions.
122 changes: 104 additions & 18 deletions README.md
Expand Up @@ -31,39 +31,125 @@ The following Client Library are central to the use of the Billogram service:

First you need to register an account. it's recommend that you sign up on Billogram sandbox environment
[Sandbox Billogram](https://billogram.com) or on [Billogram](https://billogram.com) ,then generate an API user

##### 1- How to Authentify to api :

For the authentication :
After you have generated an API user you need to create a BillogramClient and pass your user and the password to the static create function
```php
$billogramClient = BillogramClient::create(userName,password);
```

##### 2- Example :
* How to create a customer :

$httpClientConfigurator = new HttpClientConfigurator(new HttplugClient());
$httpClientConfigurator->setAuth('your Api username', 'your Api password');
$apiClient = BillogramClient::create($httpClientConfigurator);
```php
$contact = CustomerContact::createFromArray(['name' => 'ib92g', 'email' => 'ib922@gmail.com', 'phone' => '0712223344']);
$addressCustomer = CustomerBillingAddress::createFromArray(['careof' => 'ibrahim', 'use_careof_as_attention' => false, 'street_address' => 'Flygarvägen 189B', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']);
$addressDelivery = CustomerDeliveryAddress::createFromArray(['name' => 'ibrahim', 'street_address' => 'Flygarvägen 189B', 'careof' => 'ibrahim', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']);
$customer = new Model();
$customer = $customer->withCustomerNo(1);
$customer = $customer->withName('Ibrahim AA');
$customer = $customer->withNotes('aa');
$customer = $customer->withOrgNo('556801-7155');
$customer = $customer->withVatNo('SE556677889901');
$customer = $customer->withContact($contact);
$customer = $customer->withAddress($addressCustomer);
$customer = $customer->withDeliveryAddress($addressDelivery);
$customer = $customer->withCompanyType('individual');
$billogramClient = BillogramClient::create(userName,password);
$customerFinal = $billogramClient->customers()->create($customer);
```
* How to get a customer

```php
$billogramClient = BillogramClient::create(userName,password);
$customerFetched = $apiClient->customers()->fetch($customerNo, ['customer_no']);
return $customerFetched;

```

* how to create an item
```php
$bookkeeping = Bookkeeping::createFromArray(['income_account' => '302', 'vat_account' => '303']);
$item = new Item();
$item = $item->withTitle('cc');
$item = $item->withDescription('cc');
$item = $item->withPrice(12);
$item = $item->withVat(12);
$item = $item->withUnit('hour');
$item = $item->withBookkeeping($bookkeeping);
$billogramClient = BillogramClient::create(userName,password);
$itemCreated = $billogramClient->items()->create($item);
```

For example if you need to add a new invoice with a new costumer and a new item :

1- to create the models :
*create a new Costumer object (src/Model/Costumer)
*create a new Item object (src/Model/Item)
* How to fetch the items:
```php
$billogramClient = BillogramClient::create(userName,password);
$items = $apiClient->items()->search(['page' => 1]);
```

* How to delete an item
```php
$billogramClient = BillogramClient::create(userName,password);
$billogramClient->items()->delete($itemNo);
```

* How to create an invoice
We consider that you have created a customer and an item (Seed the docs above) and you will you them to create a new invoice:

2- to send Http request :
```php
$customercreated = $apiClient->customers()->create($customer);
$itemCreated = $apiClient->items()->create($item);
$billogramClient = BillogramClient::create(userName,password);
$customerFetched = $billogramClient->customers()->fetch($customerNo);

$billogramClient = BillogramClient::create(userName,password);
$itemFetched = $billogramClient->items()->fetch($itemNo);

$itemOfinvoice = new src/Model/Invoice/Item();
$itemOfinvoice = $itemOfinvoice->withItemNo($itemCreated->getItemNo());
$itemOfinvoice = $itemOfinvoice->withItemNo($itemFetched->getItemNo());
$itemOfinvoice = $itemOfinvoice->withCount(2)
$itemOfinvoice = $itemOfinvoice->withDiscount(1)
$invoice = new src/Model/Invoice/Invoice();
$invoice = $invoice->withCustomer($customer);
$invoice = $invoice->withCustomer($customerFetched);
$invoice = $invoice->withItems([$itemOfinvoice]);
$invoice = $invoice->withInvoiceDate('2013-11-14');
$cacheClient = $this->getHttpClient();
$invoiceCreated = $apiClient->invoices()->create($invoice);

$billogramClient = BillogramClient::create(userName,password);
$invoiceCreated = $billogramClient->invoices()->create($invoice);
```

* How to update the default setting of business account
```php
$setting = new Setting();
$contact = Contact::createFromArray(['name' => 'Ib92', 'phone' => '0712345678', 'email' => 'tarafder.saptad@pig.pp.ua', 'www' => 'https://www.youtube.com/']);
$address = BusinessAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden']);
$invoiceAddress = InvoiceAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden', 'email' => 'tarafder.saptad@pig.pp.ua']);
$visitingAddress = VisitingAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden']);
$payment = PaymentSetting::createFromArray(['bankgiro' => '', 'plusgiro' => '', 'domestic_bank_account' => ['account_no' => '', 'clearing_no' => ''], 'international_bank_account' => ['bank' => '', 'iban' => '', 'bic' => '', 'swift' => '']]);
$tax = TaxSetting::createFromArray(['is_vat_registered' => '', 'has_fskatt' => '', 'vat_no' => '']);
$bookkeeping = BookkeepingSetting::createFromArray(['income_account_for_vat_25' => '', 'income_account_for_vat_12' => '', 'income_account_for_vat_6' => '', 'income_account_for_vat_0' => '', 'reversed_vat_account' => '', 'vat_account_for_vat_25' => '',
'vat_account_for_vat_12' => '', 'vat_account_for_vat_6' => '', 'account_receivable_account' => '', 'client_funds_account' => '', 'banking_account' => '', 'interest_fee_account' => '', 'reminder_fee_account' => '',
'rounding_account' => '', 'factoring_receivable_account' => '', 'non_allocated_account' => '', 'income_payout_account' => '', 'written_down_receivables_account' => '', 'expected_loss_account' => '',
'regional_sweden' => ['rotavdrag_account' => ''], ]);
$invoices = InvoiceDefaults::createFromArray(['default_message' => 'hey hey', 'default_messagedefault_message' => 8.5, 'default_reminder_fee' => 10, 'default_invoice_fee' => 30,
'automatic_reminders' => ['delay_days' => 5, 'message' => 'HEY'],
'automatic_writeoff' => ['settings' => 'all_fees', 'amount' => 100],
'automatic_collection' => ['delay_days' => 5, 'amount' => 100], ]);
$setting = $setting->withName('debg');
$setting = $setting->withOrgNo('556667-0591');
$setting = $setting->withContact($contact);
$setting = $setting->withBusinessAddress($address);
$setting = $setting->withVisitingAddress($visitingAddress);
$setting = $setting->withInvoiceAddress($invoiceAddress);
$setting = $setting->withPayment($payment);
$setting = $setting->withTax($tax);
$setting = $setting->withBookkeeping($bookkeeping);
$setting = $setting->withInvoices($invoices);

$billogramClient = BillogramClient::create(userName,password);
$settingFinal = $billogramClient->settings()->update($setting);
```
## Examples
This repository contains an example API client for FakeTwitter. The API for FakeTwitter has the following endpoints.
## Endpoints
This repository contains an example API client for Billogram. The API for Billogram has the following endpoints

| Method | URI | Parameters |
| ------ | --- | ---------- |
Expand Down

0 comments on commit b39fe35

Please sign in to comment.