Skip to content

Commit

Permalink
init entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdaan committed Feb 2, 2017
0 parents commit f99a8c3
Show file tree
Hide file tree
Showing 20 changed files with 683 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending for every file
# Indent with 4 spaces
[php]
end_of_line = lf
indent_style = space
indent_size = 4
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor/
phpunit.xml
composer.phar
composer.lock
.idea
.DS_STORE
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: php

sudo: false

php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
Empty file added CHANGELOG.md
Empty file.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) Novikov Bogdan <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Empty file added README.md
Empty file.
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "bogdaan/viber-bot-php",
"description": "Php bot interface to work with Viber API",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Novikov Bogdan",
"email": "[email protected]"
}
],
"require": {
"guzzlehttp/guzzle": "^6.2"
}
}
38 changes: 38 additions & 0 deletions src/Api/Keyboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Viber\Api;

/**
* The keyboard can be attached to any message type or sent on it’s on.
* Once received, the keyboard will appear to the user instead of the device’s
* native keyboard. The client will always display the last keyboard
* that was sent to it.
*
* @see https://developers.viber.com/tools/keyboards/index.html
*/
class Keyboard
{
/**
* Array containing all keyboard buttons by order
*
* @var array
*/
protected $Buttons;

/**
* Background color of the keyboard (HEX)
*
* @var string
*/
protected $BgColor;

/**
* When true - the keyboard will always be displayed with the same height
* as the native keyboard.When false - short keyboards will be displayed
* with the minimal possible height. Maximal height will be native
* keyboard height
*
* @var boolean
*/
protected $DefaultHeight;
}
130 changes: 130 additions & 0 deletions src/Api/Keyboard/Button.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

namespace Viber\Api\Keyboard;

/**
* Keyboard button
* @see https://developers.viber.com/tools/keyboards/index.html
*/
class Button
{
/**
* Button width in columns (1-6)
*
* @var integer
*/
protected $Columns = 6;

/**
* Button height in rows (1-2)
*
* @var integer
*/
protected $Rows = 1;

/**
* Background color of button
*
* @var string
*/
protected $BgColor;

/**
* Type of the background media ("picture" or "gif")
* For picture - JPEG and PNG files are supported.
* Max size: 500 kb
*
* @var string
*/
protected $BgMediaType;

/**
* URL for background media content.
* Will be placed with aspect to fill logic.
*
* @var string
*/
protected $BgMedia;

/**
* When true - animated background media (gif) will loop continuously.
* When false - animated background media will play once and stop.
*
* @var boolean
*/
protected $BgLoop;

/**
* Type of action pressing the button will perform.
* "reply" - will send a reply to the PA.
* "open-url" - will open the specified URL and send the URL as reply to the PA.
*
* @see https://developers.viber.com/tools/keyboards/index.html#replyLogic
* @var string
*/
protected $ActionType;

/**
* Text for reply ActionType OR URL for "open-url".
* For ActionType reply - text
* For ActionType open-url - Valid URL.
* Max length: Android - 250 characters; iOS - 100 characters
*
* @var string
*/
protected $ActionBody;

/**
* URL of image to place on top of background (if any). Can be a partially
* transparent image that will allow showing some of the background.
* Will be placed with aspect to fill logic.
*
* Valid URL. JPEG and PNG files are supported. Max size: 500 kb
*
* @var string
*/
protected $Image;

/**
* Text to be displayed on the button. Can contain some HTML tags.
*
* Free text. Valid and allowed HTML tags Max 250 characters. If the text
* is too long to display on the button it will be cropped and ended
* with "..."
*
* @var string
*/
protected $Text;

/**
* Vertical alignment of the text
*
* Avail: top, middle, bottom
*
* @var string
*/
protected $TextVAlign;

/**
* Horizontal align of the text
*
* Avail: left, center, right
*
* @var string
*/
protected $TextHAlign;

/**
* Text opacity. Range: 0-100
*
* @var integer
*/
protected $TextOpacity;

/**
* Text size out of 3 available options: small, regular, large
*
* @var string
*/
protected $TextSize;
}
48 changes: 48 additions & 0 deletions src/Api/Message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Viber\Api;

/**
* Viber general message object
*
* @author Novikov Bogdan <[email protected]>
*/
class Message
{
/**
* Viber user
* @var [type]
*/
protected $receiver;

/**
* Message type
* @var [type]
*/
protected $type;

/**
* Sender information
* @var [type]
*/
protected $sender;

/**
* Allow PA to track messages and user’s replies.
* Passed back with user’s reply
* @var string
*/
protected $tracking_data;

/**
* API version required by clients
* @var integer
*/
protected $min_api_version = 1;


public function __construct($params)
{
$this->type = $this->getType();
}
}
32 changes: 32 additions & 0 deletions src/Api/Message/Contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Viber\Api\Message;

use Viber\Api\Message;

/**
* Contact as message
*/
class Contact extends Message
{
/**
* Name of the contact. Max 28 characters.
* @var string
*/
protected $name;

/**
* Phone number of the contact. Max 18 characters
* @var integer
*/
protected $phone_number;

/**
* message type
* @return [type] [description]
*/
public function getType()
{
return 'contact';
}
}
40 changes: 40 additions & 0 deletions src/Api/Message/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Viber\Api\Message;

use Viber\Api\Message;

/**
* File as message
*/
class File extends Message
{
/**
* URL of the file
* @var string
*/
protected $media;

/**
* Size of the file in bytes
* @var integer
*/
protected $size;

/**
* Name of the file.
* File name should include extension.
* Max 256 characters (including file extension)
* @var string
*/
protected $file_name;

/**
* message type
* @return [type] [description]
*/
public function getType()
{
return 'file';
}
}
26 changes: 26 additions & 0 deletions src/Api/Message/Location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Viber\Api\Message;

use Viber\Api\Message;

/**
* Location as message
*/
class Location extends Message
{
/**
* Location coordinates
* @var Location
*/
protected $location;

/**
* message type
* @return [type] [description]
*/
public function getType()
{
return 'location';
}
}
Loading

0 comments on commit f99a8c3

Please sign in to comment.