1+ <?php
2+
3+ namespace RestApis \TradingApis \ExchangeAccounts ;
4+
5+ use Common \Request ;
6+ use Common \Response ;
7+
8+ class Account extends Request {
9+
10+ protected $ endpoint = '/trading/exchange-accounts ' ;
11+
12+ /**
13+ * @param $exchange_id string
14+ * @param $exchange_api_key string
15+ * @param $exchange_secret string
16+ * @param $exchange_password string
17+ * @param $exchange_uid string
18+ * @return \stdClass
19+ */
20+ public function create ($ exchange_id , $ exchange_api_key , $ exchange_secret = null , $ exchange_password = null , $ exchange_uid = null )
21+ {
22+ $ params = [
23+ 'url ' => $ this ->getEndPoint (),
24+ 'exchange_id ' => $ exchange_id ,
25+ 'exchange_api_key ' => $ exchange_api_key
26+ ];
27+
28+ if (!is_null ($ exchange_secret )) {
29+ $ params ['exchange_secret ' ] = $ exchange_secret ;
30+ }
31+
32+ if (!is_null ($ exchange_password )) {
33+ $ params ['exchange_password ' ] = $ exchange_password ;
34+ }
35+
36+ if (!is_null ($ exchange_uid )) {
37+ $ params ['exchange_uid ' ] = $ exchange_uid ;
38+ }
39+
40+ return (new Response (
41+ $ this ->request ([
42+ 'method ' => 'POST ' ,
43+ 'params ' => $ params
44+ ])
45+ ))->get ();
46+ }
47+
48+ /**
49+ * @return \stdClass
50+ */
51+ public function listAll ()
52+ {
53+ $ params = [];
54+ return (new Response (
55+ $ this ->request ([
56+ 'method ' => 'GET ' ,
57+ 'params ' => $ params
58+ ])
59+ ))->get ();
60+ }
61+
62+
63+ /**
64+ * @param $account_id string
65+ * @return \stdClass
66+ */
67+ public function get ($ account_id )
68+ {
69+ $ params = [];
70+ return (new Response (
71+ $ this ->request ([
72+ 'method ' => 'GET ' ,
73+ 'params ' => $ params
74+ ],
75+ $ this ->getEndPoint () . '/ ' . $ account_id )
76+ ))->get ();
77+ }
78+
79+ /**
80+ * @param $account_id string
81+ * @param $exchange_id string
82+ * @param $exchange_api_key string
83+ * @param $exchange_secret string
84+ * @param $exchange_password string
85+ * @param $exchange_uid string
86+ * @return \stdClass
87+ */
88+ public function update ($ account_id , $ exchange_id = null , $ exchange_api_key = null , $ exchange_secret = null , $ exchange_password = null , $ exchange_uid = null )
89+ {
90+ $ params = [];
91+
92+ if (!is_null ($ exchange_id )) {
93+ $ params ['exchange_id ' ] = $ exchange_id ;
94+ }
95+
96+ if (!is_null ($ exchange_api_key )) {
97+ $ params ['exchange_api_key ' ] = $ exchange_api_key ;
98+ }
99+
100+ if (!is_null ($ exchange_secret )) {
101+ $ params ['exchange_secret ' ] = $ exchange_secret ;
102+ }
103+
104+ if (!is_null ($ exchange_password )) {
105+ $ params ['exchange_password ' ] = $ exchange_password ;
106+ }
107+
108+ if (!is_null ($ exchange_uid )) {
109+ $ params ['exchange_uid ' ] = $ exchange_uid ;
110+ }
111+
112+ return (new Response (
113+ $ this ->request ([
114+ 'method ' => 'PATCH ' ,
115+ 'params ' => $ params
116+ ],$ this ->getEndPoint () . '/ ' . $ account_id )
117+ ))->get ();
118+ }
119+
120+ /**
121+ * @param $account_id string
122+ * @param $exchange_id string
123+ * @param $exchange_api_key string
124+ * @param $exchange_secret string
125+ * @param $exchange_password string
126+ * @param $exchange_uid string
127+ * @return \stdClass
128+ */
129+ public function replace ($ account_id , $ exchange_id , $ exchange_api_key , $ exchange_secret = null , $ exchange_password = null , $ exchange_uid = null )
130+ {
131+ $ params = [
132+ 'exchange_id ' => $ exchange_id ,
133+ 'exchange_api_key ' => $ exchange_api_key
134+ ];
135+
136+ if (!is_null ($ exchange_secret )) {
137+ $ params ['exchange_secret ' ] = $ exchange_secret ;
138+ }
139+
140+ if (!is_null ($ exchange_password )) {
141+ $ params ['exchange_password ' ] = $ exchange_password ;
142+ }
143+
144+ if (!is_null ($ exchange_uid )) {
145+ $ params ['exchange_uid ' ] = $ exchange_uid ;
146+ }
147+
148+
149+ return (new Response (
150+ $ this ->request ([
151+ 'method ' => 'PUT ' ,
152+ 'params ' => $ params
153+ ],$ this ->getEndPoint () . '/ ' . $ account_id )
154+ ))->get ();
155+ }
156+
157+ /**
158+ * @param $account_id string
159+ * @return \stdClass
160+ */
161+ public function delete ($ account_id )
162+ {
163+ $ params = [];
164+ return (new Response (
165+ $ this ->request ([
166+ 'method ' => 'DELETE ' ,
167+ 'params ' => $ params
168+ ],
169+ $ this ->getEndPoint () . '/ ' . $ account_id )
170+ ))->get ();
171+ }
172+ }
0 commit comments