2017 © Pedro Peláez
 

library php-hipchat-connect

HipChat connect (v2) api helpers

image

jippi/php-hipchat-connect

HipChat connect (v2) api helpers

  • Wednesday, November 11, 2015
  • by jippi
  • Repository
  • 1 Watchers
  • 2 Stars
  • 77 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Introduction

This toolkit will help you construct valid HipChat connect manifest files., (*1)

It provides basic validation for the most important keys, and help you avoid hours of frustrating debugging, but guiding you through a fluent and consistent interface for configuring your HipChat Connect manifest files., (*2)

If any validation errors are found, an HipChat\Exception\ValidationException will be thrown. This exception instance have a getValidationErrorCount and getValidationErrors method to help inspect the found validation errors., (*3)

Most code currently live in the HipChat\Manifest\AbstractNode and HipChat\Manifest\Capabilities classes., (*4)

The toolkit uses cakephp/validation for data validation, (*5)

Installation

composer.json, (*6)

{
    "minimum-stability": "dev",
    "require": {
        "jippi/php-hipchat-connect": "dev-master"
    }
}

run composer install, (*7)

or, (*8)

composer require jippi/php-hipchat-connect

Example

name = 'Example App';
$generator->description = 'An integration that does wonderful things with examples';
$generator->key = 'com.example.demo';
$generator->vendor()
    ->set('name', 'Bownty')
    ->set('url', 'bownty.com');
$generator->links()
    ->set('homepage', 'https://addon.example.com/')
    ->set('self', 'https://addon.example.com/capabilities');
$generator->capabilities()
    ->webhook('email_sniffer')
        ->set('url', 'https://addon.example.com/email_sniffer')
        ->set('pattern', '[@]')
        ->set('event', 'room_message')
        ->set('authentication', 'none')
        ->set('name', 'E-mail sniffer');
$generator->capabilities()
    ->action('demo')
        ->set('key', 'message.reminder')
        ->set('name', ['value' => 'Set reminder'])
        ->set('target', 'message.reminder.dialog')
        ->set('location', 'hipchat.message.action');
$generator->capabilities()
    ->dialog('demo')
        ->set('key', 'meh')
        ->set('title', ['value' => 'Add Reminder'])
        ->set('url', 'https://addon.example.com/message/reminders')
        ->set('options', ['filter' => ['placeholder' => ['value' => 'muh']]]);
$generator->capabilities()
    ->glance('demo')
        ->set('key', 'meh')
        ->set('icon', [
            'url' => 'https://addon.example.com/small.jpg',
            'url@2x' => 'https://addon.example.com/small@2x.jpg'
        ])
        ->set('name', ['value' => 'Locked Repositories'])
        ->set('target', ['value' => 'locked.repos.sidebar'])
        ->set('queryUrl', 'https://addon.example.com/glance/example');
$generator->capabilities()
    ->installable()
        ->set('allowGlobal', true)
        ->set('allowRoom', true);

$generator->validate();

echo json_encode($generator);
?>

will output, (*9)

{
  "name": "Example App",
  "description": "An integration that does wonderful things with examples",
  "key": "com.example.demo",
  "vendor": {
    "name": "Bownty",
    "url": "bownty.com"
  },
  "links": {
    "homepage": "https://addon.example.com/",
    "self": "https://addon.example.com/capabilities"
  },
  "capabilities": {
    "action": [
      {
        "key": "message.reminder",
        "name": {
          "value": "Set reminder"
        },
        "target": "message.reminder.dialog",
        "location": "hipchat.message.action"
      }
    ],
    "webhook": [
      {
        "url": "https://addon.example.com/email_sniffer",
        "pattern": "[@]",
        "event": "room_message",
        "authentication": "none",
        "name": "E-mail sniffer"
      }
    ],
    "dialog": [
      {
        "key": "meh",
        "title": {
          "value": "Add Reminder"
        },
        "url": "https://addon.example.com/message/reminders",
        "options": {
          "filter": {
            "placeholder": {
              "value": "muh"
            }
          }
        }
      }
    ],
    "glance": [
      {
        "key": "meh",
        "icon": {
          "url": "https://addon.example.com/small.jpg",
          "url@2x": "https://addon.example.com/small@2x.jpg"
        },
        "name": {
          "value": "Locked Repositories"
        },
        "target": {
          "value": "locked.repos.sidebar"
        },
        "queryUrl": "https://addon.example.com/glance/example"
      }
    ],
    "installable": {
      "allowGlobal": true,
      "allowRoom": true
    }
  }
}

The Versions

11/11 2015

dev-master

9999999-dev

HipChat connect (v2) api helpers

  Sources   Download

MIT

The Requires

 

api hipchat hipchat-connect