Class: ZakkiStore
- Inherits:
-
Object
- Object
- ZakkiStore
- Defined in:
- lib/zakkistore-sdk.rb
Instance Attribute Summary collapse
-
#auto_withdraw ⇒ Object
Returns the value of attribute auto_withdraw.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#email ⇒ Object
Returns the value of attribute email.
-
#iduser ⇒ Object
Returns the value of attribute iduser.
-
#pin ⇒ Object
Returns the value of attribute pin.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #cancel(id_transaksi = nil, all_pending = false) ⇒ Object
- #cek_ip(ip) ⇒ Object
- #cek_my_ip ⇒ Object
- #cekgacha ⇒ Object
- #cekh2h(id_trx) ⇒ Object
- #cekip(ip) ⇒ Object
-
#cekmining(idmining) ⇒ Object
— 5.
- #cekmyip ⇒ Object
- #cektopup(idtopup) ⇒ Object
- #cektopup2(idtopup) ⇒ Object
- #check_transfer(idtransfer) ⇒ Object
-
#checkbank ⇒ Object
— 3.
- #checkmutasi(mutasi_type = "all") ⇒ Object
- #checkname(number) ⇒ Object
- #checktransfer(idtransfer) ⇒ Object
- #del_callback ⇒ Object
- #del_notif_bot ⇒ Object
- #delcallback ⇒ Object
- #delnotifbot ⇒ Object
- #delwhitelistip(ip) ⇒ Object
- #enable_auto_withdraw(status) ⇒ Object
- #enableAutoWithdraw(status) ⇒ Object
- #h2h(kode, tujuan = nil, ref_id = nil) ⇒ Object
-
#initialize(base_url = "https://qris.zakki.store", token = nil, iduser = nil, email = nil, pin = nil, auto_withdraw = false) ⇒ ZakkiStore
constructor
A new instance of ZakkiStore.
- #leaderboard(limit = 10, period = "all") ⇒ Object
-
#listkode(jenis = nil, product_type = nil) ⇒ Object
— 2.
- #mining_start ⇒ Object
- #mining_submit(nonce, signature) ⇒ Object
- #miningStart ⇒ Object
- #miningSubmit(nonce, signature) ⇒ Object
- #my_topup ⇒ Object
- #my_transfer(transfer_type = "all") ⇒ Object
- #myh2h ⇒ Object
- #mymining ⇒ Object
- #mytopup ⇒ Object
- #mytransfer(transfer_type = "all") ⇒ Object
- #noktelBuy(category) ⇒ Object
- #noktelCancel(invoice_id) ⇒ Object
- #noktelGetOtp(account_id) ⇒ Object
- #noktelHistory ⇒ Object
-
#noktelStok ⇒ Object
— 4.
-
#set_callback(site) ⇒ Object
— 7.
- #set_notif_bot(telegram_id) ⇒ Object
- #setcallback(site) ⇒ Object
- #setnotifbot(telegram_id) ⇒ Object
- #status ⇒ Object
- #tabung(jumlah) ⇒ Object
- #tarik(jumlah) ⇒ Object
-
#topup(nominal) ⇒ Object
— 1.
- #transfer(to, amount = nil) ⇒ Object
-
#whitelistip(ip) ⇒ Object
— 6.
Constructor Details
#initialize(base_url = "https://qris.zakki.store", token = nil, iduser = nil, email = nil, pin = nil, auto_withdraw = false) ⇒ ZakkiStore
Returns a new instance of ZakkiStore.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/zakkistore-sdk.rb', line 8 def initialize(base_url = "https://qris.zakki.store", token = nil, iduser = nil, email = nil, pin = nil, auto_withdraw = false) # Smart detection if token is placed in base_url parameter if base_url && !base_url.start_with?("http://") && !base_url.start_with?("https://") && token.nil? token = base_url base_url = "https://qris.zakki.store" end raise ArgumentError, "token wajib disertakan dalam konfigurasi SDK." if token.nil? || token.empty? raise ArgumentError, "base_url wajib disertakan dalam konfigurasi SDK." if base_url.nil? || base_url.empty? @base_url = base_url.chomp('/') @token = token @iduser = iduser @email = email @pin = pin @auto_withdraw = !!auto_withdraw end |
Instance Attribute Details
#auto_withdraw ⇒ Object
Returns the value of attribute auto_withdraw.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def auto_withdraw @auto_withdraw end |
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def base_url @base_url end |
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def email @email end |
#iduser ⇒ Object
Returns the value of attribute iduser.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def iduser @iduser end |
#pin ⇒ Object
Returns the value of attribute pin.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def pin @pin end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/zakkistore-sdk.rb', line 6 def token @token end |
Instance Method Details
#cancel(id_transaksi = nil, all_pending = false) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/zakkistore-sdk.rb', line 55 def cancel(id_transaksi = nil, all_pending = false) if id_transaksi.is_a?(TrueClass) || id_transaksi.is_a?(FalseClass) all_pending = id_transaksi id_transaksi = nil end payload = { "token" => @token } payload["id_transaksi"] = id_transaksi if id_transaksi payload["all"] = true if all_pending _request('/cancel', 'POST', payload) end |
#cek_ip(ip) ⇒ Object
364 365 366 |
# File 'lib/zakkistore-sdk.rb', line 364 def cek_ip(ip) _request('/cekip', 'GET', { "ip" => ip.to_s.strip }) end |
#cek_my_ip ⇒ Object
356 357 358 |
# File 'lib/zakkistore-sdk.rb', line 356 def cek_my_ip _request('/cekmyip', 'GET') end |
#cekgacha ⇒ Object
254 255 256 |
# File 'lib/zakkistore-sdk.rb', line 254 def cekgacha _request('/cekgacha', 'GET', { "token" => @token }) end |
#cekh2h(id_trx) ⇒ Object
94 95 96 |
# File 'lib/zakkistore-sdk.rb', line 94 def cekh2h(id_trx) _request('/cekh2h', 'GET', { "id" => id_trx }) end |
#cekip(ip) ⇒ Object
368 369 370 |
# File 'lib/zakkistore-sdk.rb', line 368 def cekip(ip) cek_ip(ip) end |
#cekmining(idmining) ⇒ Object
— 5. REWARD KOMPUTASI & UTILITY —
223 224 225 226 |
# File 'lib/zakkistore-sdk.rb', line 223 def cekmining(idmining) raise ArgumentError, "Parameter idmining wajib diisi." if idmining.nil? || idmining.empty? _request('/cekmining', 'GET', { "idmining" => idmining.to_s.strip }) end |
#cekmyip ⇒ Object
360 361 362 |
# File 'lib/zakkistore-sdk.rb', line 360 def cekmyip cek_my_ip end |
#cektopup(idtopup) ⇒ Object
45 46 47 48 49 |
# File 'lib/zakkistore-sdk.rb', line 45 def cektopup(idtopup) _request('/cektopup', 'GET', { "idtopup" => idtopup }) end |
#cektopup2(idtopup) ⇒ Object
51 52 53 |
# File 'lib/zakkistore-sdk.rb', line 51 def cektopup2(idtopup) "#{@base_url}/cektopup2?idtopup=#{URI.encode_www_form_component(idtopup)}" end |
#check_transfer(idtransfer) ⇒ Object
329 330 331 |
# File 'lib/zakkistore-sdk.rb', line 329 def check_transfer(idtransfer) _request('/checktransfer', 'GET', { "idtransfer" => idtransfer.to_s.strip }) end |
#checkbank ⇒ Object
— 3. PERBANKAN & TRANSFER SALDO —
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/zakkistore-sdk.rb', line 106 def checkbank payload = { "token" => @token } payload["iduser"] = @iduser if @iduser payload["email"] = @email if @email bank_res = _request('/checkbank', 'GET', payload) if @auto_withdraw && bank_res["data"] && bank_res["data"]["bank_detail"] bank_detail = bank_res["data"]["bank_detail"] balance = (bank_detail["balance"] || 0).to_f if balance > 0 begin withdraw_res = tarik(balance.to_i) bank_res = _request('/checkbank', 'GET', payload) bank_res["auto_withdraw_executed"] = true bank_res["auto_withdraw_amount"] = balance.to_i bank_res["auto_withdraw_message"] = withdraw_res["message"] || "Auto-withdraw berhasil dijalankan." rescue => err bank_res["auto_withdraw_executed"] = false bank_res["auto_withdraw_error"] = err. end end end bank_res end |
#checkmutasi(mutasi_type = "all") ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/zakkistore-sdk.rb', line 176 def checkmutasi(mutasi_type = "all") payload = { "token" => @token, "type" => mutasi_type } payload["iduser"] = @iduser if @iduser payload["email"] = @email if @email _request('/checkmutasi', 'GET', payload) end |
#checkname(number) ⇒ Object
134 135 136 |
# File 'lib/zakkistore-sdk.rb', line 134 def checkname(number) _request('/checkname', 'GET', { "number" => number.to_s.strip }) end |
#checktransfer(idtransfer) ⇒ Object
333 334 335 |
# File 'lib/zakkistore-sdk.rb', line 333 def checktransfer(idtransfer) check_transfer(idtransfer) end |
#del_callback ⇒ Object
302 303 304 |
# File 'lib/zakkistore-sdk.rb', line 302 def del_callback _request('/delcallback', 'GET', { "token" => @token }) end |
#del_notif_bot ⇒ Object
321 322 323 |
# File 'lib/zakkistore-sdk.rb', line 321 def del_notif_bot _request('/delnotifbot', 'GET', { "token" => @token }) end |
#delcallback ⇒ Object
306 307 308 |
# File 'lib/zakkistore-sdk.rb', line 306 def delcallback del_callback end |
#delnotifbot ⇒ Object
325 326 327 |
# File 'lib/zakkistore-sdk.rb', line 325 def delnotifbot del_notif_bot end |
#delwhitelistip(ip) ⇒ Object
269 270 271 272 273 274 |
# File 'lib/zakkistore-sdk.rb', line 269 def delwhitelistip(ip) _request('/delwhitelistip', 'POST', { "token" => @token, "ip" => ip.to_s.strip }) end |
#enable_auto_withdraw(status) ⇒ Object
26 27 28 |
# File 'lib/zakkistore-sdk.rb', line 26 def enable_auto_withdraw(status) @auto_withdraw = !!status end |
#enableAutoWithdraw(status) ⇒ Object
30 31 32 |
# File 'lib/zakkistore-sdk.rb', line 30 def enableAutoWithdraw(status) enable_auto_withdraw(status) end |
#h2h(kode, tujuan = nil, ref_id = nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/zakkistore-sdk.rb', line 78 def h2h(kode, tujuan = nil, ref_id = nil) if kode.is_a?(Hash) payload = kode kode = payload[:kode] || payload["kode"] tujuan = payload[:tujuan] || payload["tujuan"] ref_id = payload[:refID] || payload["refID"] || payload[:ref_id] || payload["ref_id"] end _request('/h2h', 'POST', { "token" => @token, "kode" => kode, "tujuan" => tujuan, "refID" => ref_id }) end |
#leaderboard(limit = 10, period = "all") ⇒ Object
276 277 278 279 280 281 |
# File 'lib/zakkistore-sdk.rb', line 276 def leaderboard(limit = 10, period = "all") _request('/leaderboard', 'GET', { "limit" => limit.to_i, "period" => period.to_s.strip }) end |
#listkode(jenis = nil, product_type = nil) ⇒ Object
— 2. TRANSAKSI H2H (HOST-TO-HOST) —
71 72 73 74 75 76 |
# File 'lib/zakkistore-sdk.rb', line 71 def listkode(jenis = nil, product_type = nil) payload = {} payload["jenis"] = jenis if jenis payload["type"] = product_type if product_type _request('/listkode', 'GET', payload) end |
#mining_start ⇒ Object
232 233 234 |
# File 'lib/zakkistore-sdk.rb', line 232 def mining_start _request('/mining/start', 'GET', { "token" => @token }) end |
#mining_submit(nonce, signature) ⇒ Object
240 241 242 243 244 245 246 247 248 |
# File 'lib/zakkistore-sdk.rb', line 240 def mining_submit(nonce, signature) raise ArgumentError, "Parameter nonce wajib disertakan." if nonce.nil? raise ArgumentError, "Parameter signature wajib disertakan." if signature.nil? || signature.empty? _request('/mining/submit', 'POST', { "token" => @token, "nonce" => nonce, "signature" => signature }) end |
#miningStart ⇒ Object
236 237 238 |
# File 'lib/zakkistore-sdk.rb', line 236 def miningStart mining_start end |
#miningSubmit(nonce, signature) ⇒ Object
250 251 252 |
# File 'lib/zakkistore-sdk.rb', line 250 def miningSubmit(nonce, signature) mining_submit(nonce, signature) end |
#my_topup ⇒ Object
348 349 350 |
# File 'lib/zakkistore-sdk.rb', line 348 def my_topup _request('/mytopup', 'GET', { "token" => @token }) end |
#my_transfer(transfer_type = "all") ⇒ Object
337 338 339 340 341 342 |
# File 'lib/zakkistore-sdk.rb', line 337 def my_transfer(transfer_type = "all") _request('/mytransfer', 'GET', { "token" => @token, "type" => transfer_type.to_s.strip }) end |
#myh2h ⇒ Object
98 99 100 |
# File 'lib/zakkistore-sdk.rb', line 98 def myh2h _request('/myh2h', 'GET', { "token" => @token }) end |
#mymining ⇒ Object
228 229 230 |
# File 'lib/zakkistore-sdk.rb', line 228 def mymining _request('/mymining', 'GET', { "token" => @token }) end |
#mytopup ⇒ Object
352 353 354 |
# File 'lib/zakkistore-sdk.rb', line 352 def mytopup my_topup end |
#mytransfer(transfer_type = "all") ⇒ Object
344 345 346 |
# File 'lib/zakkistore-sdk.rb', line 344 def mytransfer(transfer_type = "all") my_transfer(transfer_type) end |
#noktelBuy(category) ⇒ Object
194 195 196 197 198 199 |
# File 'lib/zakkistore-sdk.rb', line 194 def noktelBuy(category) _request('/noktel/buy', 'POST', { "token" => @token, "category" => category.to_s.strip }) end |
#noktelCancel(invoice_id) ⇒ Object
208 209 210 211 212 213 |
# File 'lib/zakkistore-sdk.rb', line 208 def noktelCancel(invoice_id) _request('/noktel/cancel', 'POST', { "token" => @token, "invoice_id" => invoice_id.to_s.strip }) end |
#noktelGetOtp(account_id) ⇒ Object
201 202 203 204 205 206 |
# File 'lib/zakkistore-sdk.rb', line 201 def noktelGetOtp(account_id) _request('/noktel/getotp', 'GET', { "token" => @token, "account_id" => account_id.to_s.strip }) end |
#noktelHistory ⇒ Object
215 216 217 |
# File 'lib/zakkistore-sdk.rb', line 215 def noktelHistory _request('/noktel/history', 'GET', { "token" => @token }) end |
#noktelStok ⇒ Object
— 4. NOKTEL MARKETPLACE (OTP VIRTUAL) —
190 191 192 |
# File 'lib/zakkistore-sdk.rb', line 190 def noktelStok _request('/noktel/stok', 'GET', { "token" => @token }) end |
#set_callback(site) ⇒ Object
— 7. METODE INTEGRASI BARU —
291 292 293 294 295 296 |
# File 'lib/zakkistore-sdk.rb', line 291 def set_callback(site) _request('/setcallback', 'GET', { "token" => @token, "site" => site.to_s.strip }) end |
#set_notif_bot(telegram_id) ⇒ Object
310 311 312 313 314 315 |
# File 'lib/zakkistore-sdk.rb', line 310 def set_notif_bot(telegram_id) _request('/setnotifbot', 'GET', { "token" => @token, "id" => telegram_id.to_s.strip }) end |
#setcallback(site) ⇒ Object
298 299 300 |
# File 'lib/zakkistore-sdk.rb', line 298 def setcallback(site) set_callback(site) end |
#setnotifbot(telegram_id) ⇒ Object
317 318 319 |
# File 'lib/zakkistore-sdk.rb', line 317 def setnotifbot(telegram_id) set_notif_bot(telegram_id) end |
#status ⇒ Object
283 284 285 |
# File 'lib/zakkistore-sdk.rb', line 283 def status _request('/status', 'GET') end |
#tabung(jumlah) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/zakkistore-sdk.rb', line 152 def tabung(jumlah) raise RuntimeError, "[ZakkiStore SDK Error] PIN transaksi diperlukan untuk melakukan transaksi tabung." unless @pin payload = { "token" => @token, "jumlah" => jumlah.to_i, "pin" => @pin } payload["iduser"] = @iduser if @iduser payload["email"] = @email if @email _request('/tabung', 'POST', payload) end |
#tarik(jumlah) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/zakkistore-sdk.rb', line 164 def tarik(jumlah) raise RuntimeError, "[ZakkiStore SDK Error] PIN transaksi diperlukan untuk melakukan transaksi tarik." unless @pin payload = { "token" => @token, "jumlah" => jumlah.to_i, "pin" => @pin } payload["iduser"] = @iduser if @iduser payload["email"] = @email if @email _request('/tarik', 'POST', payload) end |
#topup(nominal) ⇒ Object
— 1. PAYMENT GATEWAY (QRIS TOPUP) —
38 39 40 41 42 43 |
# File 'lib/zakkistore-sdk.rb', line 38 def topup(nominal) _request('/topup', 'POST', { "token" => @token, "nominal" => nominal.to_i }) end |
#transfer(to, amount = nil) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/zakkistore-sdk.rb', line 138 def transfer(to, amount = nil) if to.is_a?(Hash) payload = to to = payload[:to] || payload["to"] amount = payload[:amount] || payload["amount"] end _request('/transfer', 'POST', { "token" => @token, "to" => to, "amount" => amount.to_i }) end |
#whitelistip(ip) ⇒ Object
— 6. UTILITY & SECURITY —
262 263 264 265 266 267 |
# File 'lib/zakkistore-sdk.rb', line 262 def whitelistip(ip) _request('/whitelistip', 'POST', { "token" => @token, "ip" => ip.to_s.strip }) end |