Giter Site home page Giter Site logo

hipchatapiv2client's Introduction

Hipchat v2 Api Client

This library is unmantained. Check this fork by solutionDrive

PHP Library to process calls to Hipchat's v2 REST API

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Scrutinizer Code Quality SensioLabsInsight

This package is work in progress and some functionality is not available yet.

Installation

The recommended way to install Hipchatv2ApiClient is through Composer. To install this library, run the command below and you will get the latest version:

composer require gorkalaucirica/hipchat-v2-api-client

Usage

All queries need the following two lines. The first one is to authenticate yourself and the second one creates a client that is used by the API classes to perform requests to the API. That is enough to start, now check the API calls section to see how to use the $client to send requests to the API.

use GorkaLaucirica\HipchatAPIv2Client\Auth\OAuth2;
use GorkaLaucirica\HipchatAPIv2Client\Client;

$auth = new OAuth2('tokenYouCanGetInHipchatSite');
$client = new Client($auth);

Client for private instances

After version 1.5.0 you can set the URL in the constructor to change the base url used by the client (by default uses https://api.hipchat.com

$client = new Client($auth, null, 'https.//api.yourdomain.com');

API calls

All API call methods are located in the API folder. All of them have been documented and all have a link to Hipchat v2 API documentation. Some examples:

Getting user by mention name:

use GorkaLaucirica\HipchatAPIv2Client\API\UserAPI;

$userAPI = new UserAPI($client);
$user = $userAPI->getUser('@gorkalaucirica');

Getting all rooms

use GorkaLaucirica\HipchatAPIv2Client\API\RoomAPI;

$roomAPI = new RoomAPI($client);
$room = $roomAPI->getRooms(array('max-results' => 30));

Current status

The following list shows methods available and missing:

Add ons

  • Get addon installable data
  • Create addon link
  • Invoke addon link
  • Delete addon link

Capabilities

  • Get capabilities

Emoticons

  • Get emoticon
  • Get all emoticons

OAuth Sessions

  • Generate token
  • Get session
  • Delete session

Rooms

  • Get all rooms
  • Create room
  • Get room
  • Update room
  • Delete room
  • Get avatar
  • Update avatar
  • Delete avatar
  • Get room message
  • View room history
  • View recent room history
  • Invite user
  • Add member
  • Remove member
  • Get all members
  • Send message
  • Send room notification
  • Get all participants
  • Reply to message
  • Share file with room
  • Get room statistics
  • Set topic
  • Get webhook
  • Delete webhook
  • Get all webhooks
  • Create webhook

Users

  • Get all users
  • Create user
  • View user
  • Update user
  • Delete user
  • Get privatechat message
  • View recent privatechat history
  • Private message user
  • Get photo
  • Upload photo
  • Delete photo
  • Get auto join rooms
  • Share file with user
  • Share link with user

hipchatapiv2client's People

Contributors

acedude avatar amochohan avatar andypoorman avatar antoinelemaire avatar eleclerc avatar gorkalaucirica avatar josephblock avatar rounoff avatar tschuermans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hipchatapiv2client's Issues

+1 for Emoticon API Support

Just wanted to log an issue as a vote to have the emoticon support added soon. You know, the important things. ;)

RequestException constructor warnings

In Client.php the lines
throw new RequestException($e->getMessage());
causes PHP warnings sometimes, because of the constructor that needs an array as param

Value None for field 'from' is not of type 'string' (0)

The from in the Message model is null by default but since yesterday (07-10-2015) this started throwing the following error:

Value None for field 'from' is not of type 'string' (0)

And when I changed the value null to an empty string:

protected $from = '';

Everything worked again.

The code I am talking about can be found at: Model/Message.php#L20

webhook

Hi, I'd like to start working on webhook support (Get All, Create, Get, Delete), was there any plan for this? I don't want to go against the plan if any. I was thinking of creating a Webhook model and start by implementing the 4 API functions as a first step. any thoughts?

Frequent timeouts

I'm seeing frequent timeouts when calling the userAPI->createUser() method. The following stack trace is shown.

Fatal error: Uncaught exception 'Buzz\Exception\ClientException' with message 'Operation timed out after 5216 milliseconds with 0 out of -1 bytes received' in /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php:29
Stack trace:
#0 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(130): Buzz\Client\Curl->send(Object(Buzz\Message\Request), Object(Buzz\Message\Response))
#1 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(82): Buzz\Browser->send(Object(Buzz\Message\Request))
#2 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(36): Buzz\Browser->call('https://api.hip...', 'POST', Array, '{"name":"Develo...')
#3 /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/gorkalaucirica/hipchat-v2-api-client/GorkaLaucirica/HipchatAPIv2Client/Client.php(93): Buzz\Browser->post('https://api.hip...', Array, '{"name":"Develo...')
#4 /Users/mzampetti0264/projects in /Users/mzampetti0264/projects/ie/tools/hipchat/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php on line 29

There doesn't appear to be a way to set the timeout or other Curl options, even though the underlying Buzz client allows it.

Packagist Stable Branch

I am about to utilize this package in a project, and I always cringe at the idea of using dev-master (or any unstable branch).

Is there anyway you could make a stable tag or branch that I can use instead of dev-master?

Thanks

Get photo

Try to get photo from UserAPI

$response = $this->client->get(
    sprintf('/v2/user/%s/photo/%s', $userId, $size)
);

https://api.hipchat.com/v2/user/@MyName/photo/small

Get HTTP/1.1 400 Bad Request

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>InvalidArgument</Code>
    <Message>Unsupported Authorization Type</Message>
    <ArgumentName>Authorization</ArgumentName>
    <ArgumentValue>Bearer FxxxxxxxxxxxxxxxxxxxxxxxTE0</ArgumentValue>
    <RequestId>3F1B465075D3B6E3</RequestId>
    <HostId>DjrScqVdt4WUjyUEvaay3gHhvVO/UZ1efxb6WHrqz2ZkWNFBkLkFGKs3vktPjV5j</HostId>
</Error>

(Bearer value is exactly the same as my others requests who succeed)

Is @all or @user not supported?

Im trying to notify room users using @ALL but when the message is posted its not being parsed by hipchat, its just showing as a string.

<?php 
$hipChatMsg = [
    'color' => 'red',
    'notify' => true,
    'message' => '@all hello world',
];

$roomAPI->sendRoomNotification('Alerts', new Message($hipChatMsg));

Integration oauth

Will there be support for handling integration oauth tokens?
Right now it looks like there is only support for personal oauth tokens.

sendRoomNotification fails if a a custom message is sent

In case i want to send this:

$auth = new OAuth2('myToken');
$client = new Client($auth);
$roomAPI = new RoomAPI($client);
$message = new Message([
    'id' => 'someId',
    'from' => 'someName',
    'color' => 'someColor',
    'notify' => true,
    'message' => 'SomeMessage',
    'date' => 'someDate'
]);
$roomAPI->sendRoomNotification('myRoomId', $message);

i get this error:

Value None for field 'notify' is not of type [{'type': 'string'}, {'type': 'boolean'}] on Client.php line 114. After investigating some more the POST request is sent with notify: null. Since notify is not sent, i think this $this->notify = $json['notify']; should be added to the bottom of parseJson($json) for Message model:

public function parseJson($json)
{
        $this->id = $json['id'];
        $this->from = is_array($json['from']) ? $json['from']['name'] : $json['from'];
        $this->message = $json['message'];
        $this->color = isset($json['color']) ? $json['color'] : null;
        $this->messageFormat = isset($json['message_format']) ? $json['message_format'] : 'html';
        $this->date = $json['date'];
        $this->notify = $json['notify'];
}

Room toJson fails when room doesn't have an owner

I have a couple of rooms that don't have owners, which causes toJson to fail when called on those rooms.

While this may be a bug in HipChat, there should be a null check in toJson for when the owner is null.

guzzle

Any interest in switching this to use guzzle? Should make it more future proof for php7+
This may also help getting the share/file working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.