Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Airtime
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
opensources
Airtime
Commits
6a7423da
Commit
6a7423da
authored
May 24, 2017
by
Camoo Sarl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test mode option added
parent
c0aee634
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
15 deletions
+41
-15
example-airtime.php
examples/example-airtime.php
+6
-1
Airtime.php
src/CAMOO/Airtime/Airtime.php
+5
-0
Payload.php
src/CAMOO/Airtime/Payload.php
+20
-12
Client.php
src/CAMOO/Client.php
+10
-2
No files found.
examples/example-
getMsisdnInfo
.php
→
examples/example-
airtime
.php
View file @
6a7423da
...
...
@@ -3,9 +3,14 @@ require_once('src/autoload.php');
$oAirtime
=
new
\CAMOO\Airtime\Airtime
(
'592595095gh57'
,
'4e32da5979879b89479847b9798479494984'
);
// receiver recipient
$oAirtime
->
destination_msisdn
=
'237671234567'
;
$oAirtime
->
topup
=
1500
;
// airtime from
$oAirtime
->
msisdn
=
'237340404'
;
// airtime amount
$oAirtime
->
topup
=
100
;
// just to test
$oAirtime
->
test_mode
=
true
;
/*
$oAirtime->send_sms=true;
$oAirtime->sms='Developer own custom message';
...
...
src/CAMOO/Airtime/Airtime.php
View file @
6a7423da
...
...
@@ -30,7 +30,12 @@ class Airtime extends Client{
}
public
function
__set
(
$property
,
$value
)
{
try
{
Payload
::
create
()
->
set
(
$property
,
$value
);
}
catch
(
CamooException
$err
)
{
echo
$err
->
getMessage
();
exit
();
}
return
$this
;
}
...
...
src/CAMOO/Airtime/Payload.php
View file @
6a7423da
...
...
@@ -9,7 +9,7 @@ namespace CAMOO\Airtime;
* File: src/CAMOO/Airtime/Payload.php
* updated: Mai 2017
* Created by: Epiphane Tchabom (e.tchabom@camoo.cm)
* Description: CAMOO Airtime API
* Description: CAMOO Airtime API
Payload
*
* @link http://www.camoo.cm
*/
...
...
@@ -19,6 +19,7 @@ use Valitron\Validator;
use
CAMOO\Exceptions\CamooException
;
final
class
Payload
{
private
$destination_msisdn
=
null
;
private
$msisdn
=
null
;
private
$topup
=
null
;
...
...
@@ -26,6 +27,17 @@ final class Payload{
private
$sms
=
null
;
private
$sender_sms
=
false
;
private
$sender_text
=
null
;
private
$test_mode
=
false
;
protected
static
$_create
=
null
;
public
static
function
create
()
{
if
(
is_null
(
static
::
$_create
)
)
{
static
::
$_create
=
new
self
;
}
return
static
::
$_create
;
}
private
function
ValidatorDefault
(
Validator
$oValidator
)
{
$oValidator
...
...
@@ -37,12 +49,14 @@ final class Payload{
$oValidator
->
rule
(
'required'
,
[
'destination_msisdn'
,
'topup'
,
'msisdn'
]);
$oValidator
->
rule
(
'optional'
,
[
'sms'
,
'sender_sms'
]);
->
rule
(
'optional'
,
[
'sms'
,
'sender_sms'
,
'test_mode'
]);
$oValidator
->
rule
(
'boolean'
,
'send_sms'
);
$oValidator
->
rule
(
'boolean'
,
'sender_sms'
);
$oValidator
->
rule
(
'boolean'
,
'test_mode'
);
$this
->
notBlankRule
(
$oValidator
,
'topup'
);
return
$oValidator
;
}
...
...
@@ -56,21 +70,15 @@ final class Payload{
return
false
;
}
return
true
;
},
$sParam
)
->
message
(
"
{
field
}
failed
..."
);
},
$sParam
)
->
message
(
"
{
field
}
can not be blank/empty
..."
);
}
protected
static
$_create
=
null
;
public
static
function
create
()
{
if
(
is_null
(
static
::
$_create
)
)
{
static
::
$_create
=
new
self
;
}
return
static
::
$_create
;
}
public
function
set
(
$sProperty
,
$value
)
{
if
(
!
property_exists
(
$this
,
$sProperty
)
)
{
throw
new
CamooException
([
$sProperty
=>
'is not allowed!'
]);
}
$this
->
$sProperty
=
$value
;
}
...
...
src/CAMOO/Client.php
View file @
6a7423da
...
...
@@ -31,10 +31,18 @@ class Client {
}
public
function
post
(
$data
=
[])
{
return
$this
->
oHttpClient
->
performRequest
(
static
::
REQUEST_POST
,
[
'form_params'
=>
$data
]);
try
{
return
$this
->
oHttpClient
->
performRequest
(
static
::
REQUEST_POST
,
[
'form_params'
=>
$data
]);
}
catch
(
HttpClientException
$err
)
{
echo
$err
->
getMessage
();
}
}
public
function
get
(
$data
=
[])
{
return
$this
->
oHttpClient
->
performRequest
(
static
::
REQUEST_GET
,
[
'query'
=>
$data
]);
try
{
return
$this
->
oHttpClient
->
performRequest
(
static
::
REQUEST_GET
,
[
'query'
=>
$data
]);
}
catch
(
HttpClientException
$err
)
{
echo
$err
->
getMessage
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment