Code Monkey home page Code Monkey logo

spark's Introduction

spark

Golang client for Cisco Spark API

Supported API calls

Rooms

Method Description Example
ListRooms Lists Rooms Available
GetRoom Gets a Room with a Room ID
GetRoomWithName Gets the first Room where Name matches

Messages

Method Description Example
ListMessages Lists all messages in a Room
CreateMessage Creates a message to a Room
GetMessage Gets a message by Id

Webhooks

Method Description Example
CreateWebhook Creates a new webhook
ListWebhooks Lists existing webhooks
DeleteWebhook Deletes a webhook given a webhook ID

Example

package main

import (
  "github.com/vallard/spark"
)

const (
  token       = "your-spark-access-id"
  roomName = "your-spark-room-name"
)

func main() {
  s := spark.New(token)
  
  // Get the room ID of the room name
  room, err := s.GetRoomWithName(roomName)
  
  if err != nil {
  	panic(err)
  }
  
  // Create the message we want to send
  m := spark.Message{
  	RoomId: room.Id
  	Markdown: "# Big Message right here!"
  }
  
  // Post the message to the room
  _, err := s.CreateMessage(m)
  
  if err != nil {
    panic(err)
  }
}

Read the test cases for more ways to use the library.

Inspiration

bluele/slack

spark's People

Contributors

vallard avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rmacster kaedys

spark's Issues

Cannot send private message

Sending a message via the CreateMessage API endpoint allows calls with only an email or personID, which then sends the message as a private message. However, this library immediately errors during CreateMessage if the RoomID is not set. RoomID is only needed if sending a message to a channel, rather than a private message. This error case makes sending private messages impossible unless one knows the roomID for that private message, which prevents creating new private message conversations (as those have no roomID before the first message).

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.