Skip to content

Commit ec0a275

Browse files
authored
Merge pull request #23 from xavierhb/add_statics
Add statics
2 parents a5e774c + b83a9ce commit ec0a275

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,33 @@ Convert posted data to a model
7878
$client = Client::hydrate($input);
7979

8080
*Currently supported for clients, invoices, quotes and payments*
81+
82+
## Statics
83+
84+
*Retrieve the static dataset Invoice Ninja uses*
85+
86+
Get all statics
87+
88+
Statics::all();
89+
90+
Get specific static
91+
92+
Statics::countries();
93+
94+
List of available statics
95+
96+
Statics::currencies();
97+
Statics::sizes();
98+
Statics::timezones();
99+
Statics::dateFormats();
100+
Statics::datetimeFormats();
101+
Statics::languages();
102+
Statics::paymentTerms();
103+
Statics::paymentTypes();
104+
Statics::countries();
105+
Statics::invoiceDesigns();
106+
Statics::invoiceStatus();
107+
Statics::frequencies();
108+
Statics::gateways();
109+
Statics::fonts();
110+
Statics::banks();
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php namespace InvoiceNinja\Models;
2+
3+
use stdClass;
4+
5+
class Statics extends AbstractModel
6+
{
7+
public static $route = 'static';
8+
9+
public static function all()
10+
{
11+
$url = static::getRoute() . '/';
12+
13+
return static::sendRequest($url, false, 'GET', true);
14+
}
15+
16+
public static function get($static)
17+
{
18+
return json_decode(static::all(), true)['data'][$static];
19+
}
20+
21+
public static function countries()
22+
{
23+
return static::get('countries');
24+
}
25+
26+
public static function currencies()
27+
{
28+
return static::get('currencies');
29+
}
30+
31+
public static function sizes()
32+
{
33+
return static::get('sizes');
34+
}
35+
36+
public static function industries()
37+
{
38+
return static::get('industries');
39+
}
40+
41+
public static function timezones()
42+
{
43+
return static::get('timezones');
44+
}
45+
46+
public static function dateFormats()
47+
{
48+
return static::get('dateFormats');
49+
}
50+
51+
public static function datetimeFormats()
52+
{
53+
return static::get('datetimeFormats');
54+
}
55+
56+
public static function languages()
57+
{
58+
return static::get('languages');
59+
}
60+
61+
public static function paymentTerms()
62+
{
63+
return static::get('paymentTypes');
64+
}
65+
66+
public static function invoiceDesigns()
67+
{
68+
return static::get('invoiceDesigns');
69+
}
70+
71+
public static function invoiceStatus()
72+
{
73+
return static::get('invoiceStatus');
74+
}
75+
76+
public static function frequencies()
77+
{
78+
return static::get('frequencies');
79+
}
80+
81+
public static function gateways()
82+
{
83+
return static::get('gateways');
84+
}
85+
86+
public static function fonts()
87+
{
88+
return static::get('fonts');
89+
}
90+
91+
public static function banks()
92+
{
93+
return static::get('banks');
94+
}
95+
}

0 commit comments

Comments
 (0)