Skip to content

Commit b39fe35

Browse files
IbrahimhizeouiNyholm
authored andcommitted
Readme (#32)
* Readme file * improve the readme file
1 parent 0854dcc commit b39fe35

File tree

1 file changed

+104
-18
lines changed

1 file changed

+104
-18
lines changed

README.md

Lines changed: 104 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,125 @@ The following Client Library are central to the use of the Billogram service:
3131

3232
First you need to register an account. it's recommend that you sign up on Billogram sandbox environment
3333
[Sandbox Billogram](https://billogram.com) or on [Billogram](https://billogram.com) ,then generate an API user
34+
35+
##### 1- How to Authentify to api :
3436

35-
For the authentication :
37+
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
38+
```php
39+
$billogramClient = BillogramClient::create(userName,password);
40+
```
3641

42+
##### 2- Example :
43+
* How to create a customer :
3744

38-
$httpClientConfigurator = new HttpClientConfigurator(new HttplugClient());
39-
$httpClientConfigurator->setAuth('your Api username', 'your Api password');
40-
$apiClient = BillogramClient::create($httpClientConfigurator);
45+
```php
46+
$contact = CustomerContact::createFromArray(['name' => 'ib92g', 'email' => '[email protected]', 'phone' => '0712223344']);
47+
$addressCustomer = CustomerBillingAddress::createFromArray(['careof' => 'ibrahim', 'use_careof_as_attention' => false, 'street_address' => 'Flygarvägen 189B', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']);
48+
$addressDelivery = CustomerDeliveryAddress::createFromArray(['name' => 'ibrahim', 'street_address' => 'Flygarvägen 189B', 'careof' => 'ibrahim', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']);
49+
$customer = new Model();
50+
$customer = $customer->withCustomerNo(1);
51+
$customer = $customer->withName('Ibrahim AA');
52+
$customer = $customer->withNotes('aa');
53+
$customer = $customer->withOrgNo('556801-7155');
54+
$customer = $customer->withVatNo('SE556677889901');
55+
$customer = $customer->withContact($contact);
56+
$customer = $customer->withAddress($addressCustomer);
57+
$customer = $customer->withDeliveryAddress($addressDelivery);
58+
$customer = $customer->withCompanyType('individual');
59+
$billogramClient = BillogramClient::create(userName,password);
60+
$customerFinal = $billogramClient->customers()->create($customer);
61+
```
62+
* How to get a customer
4163

64+
```php
65+
$billogramClient = BillogramClient::create(userName,password);
66+
$customerFetched = $apiClient->customers()->fetch($customerNo, ['customer_no']);
67+
return $customerFetched;
68+
69+
```
4270

71+
* how to create an item
72+
```php
73+
$bookkeeping = Bookkeeping::createFromArray(['income_account' => '302', 'vat_account' => '303']);
74+
$item = new Item();
75+
$item = $item->withTitle('cc');
76+
$item = $item->withDescription('cc');
77+
$item = $item->withPrice(12);
78+
$item = $item->withVat(12);
79+
$item = $item->withUnit('hour');
80+
$item = $item->withBookkeeping($bookkeeping);
81+
$billogramClient = BillogramClient::create(userName,password);
82+
$itemCreated = $billogramClient->items()->create($item);
83+
```
4384

44-
For example if you need to add a new invoice with a new costumer and a new item :
45-
46-
1- to create the models :
47-
*create a new Costumer object (src/Model/Costumer)
48-
*create a new Item object (src/Model/Item)
85+
* How to fetch the items:
86+
```php
87+
$billogramClient = BillogramClient::create(userName,password);
88+
$items = $apiClient->items()->search(['page' => 1]);
89+
```
90+
91+
* How to delete an item
92+
```php
93+
$billogramClient = BillogramClient::create(userName,password);
94+
$billogramClient->items()->delete($itemNo);
95+
```
96+
97+
* How to create an invoice
98+
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:
4999

50-
2- to send Http request :
51100
```php
52-
$customercreated = $apiClient->customers()->create($customer);
53-
$itemCreated = $apiClient->items()->create($item);
101+
$billogramClient = BillogramClient::create(userName,password);
102+
$customerFetched = $billogramClient->customers()->fetch($customerNo);
103+
104+
$billogramClient = BillogramClient::create(userName,password);
105+
$itemFetched = $billogramClient->items()->fetch($itemNo);
106+
54107
$itemOfinvoice = new src/Model/Invoice/Item();
55-
$itemOfinvoice = $itemOfinvoice->withItemNo($itemCreated->getItemNo());
108+
$itemOfinvoice = $itemOfinvoice->withItemNo($itemFetched->getItemNo());
56109
$itemOfinvoice = $itemOfinvoice->withCount(2)
57110
$itemOfinvoice = $itemOfinvoice->withDiscount(1)
58111
$invoice = new src/Model/Invoice/Invoice();
59-
$invoice = $invoice->withCustomer($customer);
112+
$invoice = $invoice->withCustomer($customerFetched);
60113
$invoice = $invoice->withItems([$itemOfinvoice]);
61114
$invoice = $invoice->withInvoiceDate('2013-11-14');
62-
$cacheClient = $this->getHttpClient();
63-
$invoiceCreated = $apiClient->invoices()->create($invoice);
115+
116+
$billogramClient = BillogramClient::create(userName,password);
117+
$invoiceCreated = $billogramClient->invoices()->create($invoice);
118+
```
119+
120+
* How to update the default setting of business account
121+
```php
122+
$setting = new Setting();
123+
$contact = Contact::createFromArray(['name' => 'Ib92', 'phone' => '0712345678', 'email' => '[email protected]', 'www' => 'https://www.youtube.com/']);
124+
$address = BusinessAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden']);
125+
$invoiceAddress = InvoiceAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden', 'email' => '[email protected]']);
126+
$visitingAddress = VisitingAddress::createFromArray(['street_address' => 'Finlandsgatan 36', 'careof' => 'Microsoft', 'zipcode' => '164 74', 'city' => 'Kista', 'country' => 'Sweden']);
127+
$payment = PaymentSetting::createFromArray(['bankgiro' => '', 'plusgiro' => '', 'domestic_bank_account' => ['account_no' => '', 'clearing_no' => ''], 'international_bank_account' => ['bank' => '', 'iban' => '', 'bic' => '', 'swift' => '']]);
128+
$tax = TaxSetting::createFromArray(['is_vat_registered' => '', 'has_fskatt' => '', 'vat_no' => '']);
129+
$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' => '',
130+
'vat_account_for_vat_12' => '', 'vat_account_for_vat_6' => '', 'account_receivable_account' => '', 'client_funds_account' => '', 'banking_account' => '', 'interest_fee_account' => '', 'reminder_fee_account' => '',
131+
'rounding_account' => '', 'factoring_receivable_account' => '', 'non_allocated_account' => '', 'income_payout_account' => '', 'written_down_receivables_account' => '', 'expected_loss_account' => '',
132+
'regional_sweden' => ['rotavdrag_account' => ''], ]);
133+
$invoices = InvoiceDefaults::createFromArray(['default_message' => 'hey hey', 'default_messagedefault_message' => 8.5, 'default_reminder_fee' => 10, 'default_invoice_fee' => 30,
134+
'automatic_reminders' => ['delay_days' => 5, 'message' => 'HEY'],
135+
'automatic_writeoff' => ['settings' => 'all_fees', 'amount' => 100],
136+
'automatic_collection' => ['delay_days' => 5, 'amount' => 100], ]);
137+
$setting = $setting->withName('debg');
138+
$setting = $setting->withOrgNo('556667-0591');
139+
$setting = $setting->withContact($contact);
140+
$setting = $setting->withBusinessAddress($address);
141+
$setting = $setting->withVisitingAddress($visitingAddress);
142+
$setting = $setting->withInvoiceAddress($invoiceAddress);
143+
$setting = $setting->withPayment($payment);
144+
$setting = $setting->withTax($tax);
145+
$setting = $setting->withBookkeeping($bookkeeping);
146+
$setting = $setting->withInvoices($invoices);
147+
148+
$billogramClient = BillogramClient::create(userName,password);
149+
$settingFinal = $billogramClient->settings()->update($setting);
64150
```
65-
## Examples
66-
This repository contains an example API client for FakeTwitter. The API for FakeTwitter has the following endpoints.
151+
## Endpoints
152+
This repository contains an example API client for Billogram. The API for Billogram has the following endpoints
67153

68154
| Method | URI | Parameters |
69155
| ------ | --- | ---------- |

0 commit comments

Comments
 (0)