Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/line/line-bot-sdk-php into …
Browse files Browse the repository at this point in the history
…add-get-number-of-messages
  • Loading branch information
moririnson committed Apr 17, 2019
2 parents 047e710 + 2b8df4a commit 0b498de
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 33 deletions.
86 changes: 53 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
line-bot-sdk-php
==
# LINE Messaging API SDK for PHP

[![Build Status](https://travis-ci.org/line/line-bot-sdk-php.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-php)

SDK of the LINE Messaging API for PHP.

About the LINE Messaging API
--
## Introduction

The LINE Messaging API SDK for PHP makes it easy to develop bots using LINE Messaging API, and you can create a sample bot within minutes.


## Documentation

See the official API documentation for more information.

English: [https://developers.line.me/en/docs/](https://developers.line.me/en/docs/)<br>
Japanese: [https://developers.line.me/ja/docs/](https://developers.line.me/ja/docs/)
- English: https://developers.line.biz/en/docs/messaging-api/overview/
- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/


## Requirements

- PHP 5.5 or later

Installation
--

## Installation

Install the LINE Messaging API SDK using [Composer](https://getcomposer.org/).

```
$ composer require linecorp/line-bot-sdk
```

Getting started
--
## Getting started

### Create the bot client instance

Expand Down Expand Up @@ -66,8 +72,7 @@ echo $response->getHTTPStatus() . ' ' . $response->getRawBody();
`LINEBot#replyMessage()` takes the reply token and `MessageBuilder`.
The method sends a message that is built by `MessageBuilder` to the destination.

Components
--
## Components

### MessageBuilder

Expand Down Expand Up @@ -134,7 +139,7 @@ The following examples show how webhooks are handled:
More information
--

For more information, see the [official API documents](#about-the-line-messaging-api) and PHPDoc.
For more information, see the [official API documents](#documentation) and PHPDoc.
If it's your first time using this library, we recommend taking a look at `examples` and the PHPDoc of `\LINE\LINEBot`.

Hints
Expand Down Expand Up @@ -166,7 +171,7 @@ The HTML files are generated in `docs/`.

### Official API documentation

[Official API documents](#about-the-line-messaging-api) shows the detail of Messaging API and fundamental usage of SDK.
[Official API documents](#documentation) shows the detail of Messaging API and fundamental usage of SDK.

Notes
--
Expand All @@ -178,15 +183,6 @@ Notes

Please refer [CurlHTTPClient](/src/LINEBot/HTTPClient/CurlHTTPClient.php) that is the default HTTP client implementation.

Requirements
--

- PHP 5.5 or later

For SDK developers
--

Please refer [HACKING.md](/HACKING.md).

See also
--
Expand All @@ -196,21 +192,45 @@ See also
A very simple SDK (subset) for the LINE Messaging API for PHP.
line-bot-sdk-tiny provides a simple interface and functions which makes it a good way to learn how to use the LINE Messaging API.

License
--
## Help and media

FAQ: https://developers.line.biz/en/faq/

Community Q&A: https://www.line-community.me/questions

News: https://developers.line.biz/en/news/

Twitter: [@LINE_DEV](https://twitter.com/LINE_DEV)


## Versioning

This project respects semantic versioning.

See http://semver.org/


## Contributing

Please check [CONTRIBUTING](contributing.md) before making a contribution.

For hacking instructions, please refer [HACKING.md](/HACKING.md).


## License

```
Copyright 2016 LINE Corporation
LINE Corporation licenses this file to you under the Apache License,
version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at:
Licensed under the Apache License, version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
4 changes: 4 additions & 0 deletions src/LINEBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use LINE\LINEBot\RichMenuBuilder;
use ReflectionClass;
use DateTime;
use DateTimeZone;

/**
* A client class of LINE Messaging API.
Expand Down Expand Up @@ -490,6 +491,7 @@ public function getRichMenuList()
public function getNumberOfSentReplyMessages(DateTime $datetime)
{
$url = $this->endpointBase . '/v2/bot/message/delivery/reply';
$datetime->setTimezone(new DateTimeZone('Asia/Tokyo'));
return $this->httpClient->get($url, ['date' => $datetime->format('Ymd')]);
}

Expand All @@ -502,6 +504,7 @@ public function getNumberOfSentReplyMessages(DateTime $datetime)
public function getNumberOfSentPushMessages(DateTime $datetime)
{
$url = $this->endpointBase . '/v2/bot/message/delivery/push';
$datetime->setTimezone(new DateTimeZone('Asia/Tokyo'));
return $this->httpClient->get($url, ['date' => $datetime->format('Ymd')]);
}

Expand All @@ -514,6 +517,7 @@ public function getNumberOfSentPushMessages(DateTime $datetime)
public function getNumberOfSentMulticastMessages(DateTime $datetime)
{
$url = $this->endpointBase . '/v2/bot/message/delivery/multicast';
$datetime->setTimezone(new DateTimeZone('Asia/Tokyo'));
return $this->httpClient->get($url, ['date' => $datetime->format('Ymd')]);
}
}
4 changes: 4 additions & 0 deletions tests/LINEBot/GetNumberOfSendMessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use LINE\Tests\LINEBot\Util\DummyHttpClient;
use PHPUnit\Framework\TestCase;
use DateTime;
use DateTimeZone;

class GetNumberOfMessagesSentTest extends TestCase
{
Expand All @@ -32,6 +33,7 @@ public function testGetNumberOfSentReplyMessages()
/** @var \PHPUnit\Framework\TestCase $testRunner */
$testRunner->assertEquals('GET', $httpMethod);
$testRunner->assertEquals('https://api.line.me/v2/bot/message/delivery/reply', $url);
$date->setTimezone(new DateTimeZone('Asia/Tokyo'));
$testRunner->assertEquals([
'date' => $date->format('Ymd')
], $data);
Expand All @@ -58,6 +60,7 @@ public function testGetNumberOfSentPushMessages()
/** @var \PHPUnit\Framework\TestCase $testRunner */
$testRunner->assertEquals('GET', $httpMethod);
$testRunner->assertEquals('https://api.line.me/v2/bot/message/delivery/push', $url);
$date->setTimezone(new DateTimeZone('Asia/Tokyo'));
$testRunner->assertEquals([
'date' => $date->format('Ymd')
], $data);
Expand All @@ -84,6 +87,7 @@ public function testGetNumberOfSentMulticastMessages()
/** @var \PHPUnit\Framework\TestCase $testRunner */
$testRunner->assertEquals('GET', $httpMethod);
$testRunner->assertEquals('https://api.line.me/v2/bot/message/delivery/multicast', $url);
$date->setTimezone(new DateTimeZone('Asia/Tokyo'));
$testRunner->assertEquals([
'date' => $date->format('Ymd')
], $data);
Expand Down

0 comments on commit 0b498de

Please sign in to comment.