GithubHelp home page GithubHelp logo

frousselet / blueprints Goto Github PK

View Code? Open in Web Editor NEW

This project forked from connect-blueprint/blueprints

0.0 0.0 0.0 1.13 MB

Everything you need to extend Apple Shortcut.

License: MIT License

JavaScript 100.00%

blueprints's Introduction

Blueprint

Everything you need to extend Apple Shortcut.

Framework

// When user request Blueprint inputs
Blueprint.onListInputs = async function() {
    
    // Create inputs with
    // Blueprint.newInput(id, name, type)    
  
    // Create a `text` input
    let statusText = Blueprint.newInput("status_text", "Status Message", "text")
    
    // Create a `date` input
    let statusExpiration = Blueprint.newInput("status_expiration", "Status Expiration Date", "date")
    
    // Create a `select` input...
    let statusEmoji = Blueprint.newInput("status_emoji", "Status Emoji", "select")    
    // and when user request statusEmoji options...
    statusEmoji.onListOptions = async function() {        
        //  add some options with
        // .newOption(id, name, icon?)
        statusEmoji.newOption(":coffee:", "โ˜•๏ธ Coffee")
        statusEmoji.newOption(":croissant:", "๐Ÿฅ Croissant")
    }
    
}


// When user run the Blueprint
Blueprint.onExecution = async function() {
  
  // Get user input values with
  // Blueprint.userInputs.input_id
  const requestBody = {
      profile: {
          status_text: Blueprint.userInputs.status_text,          
          status_expiration: Blueprint.userInputs.status_expiration,
          status_emoji: Blueprint.userInputs.status_emoji
      }
  }
  
  // Get user preference value with
  // Blueprint.userPreferences.preference_id
  const headers = {
      "Authorization": "Bearer " + Blueprint.userPreferences.slack_token,
      "Content-Type": "application/json;charset=UTF-8",
  };
  
  // Call API with 
  // UrlFetch(url, options?)
  const response = await UrlFetch("https://slack.com/api/users.profile.set", {
    method: "post",
    headers: headers,
    body: JSON.stringify(requestBody),
  });
    
  // Use print(string) for debugging 
  print(response)
  
  const json = JSON.parse(response)
  
  // Create result
  Blueprint.newResult("success","Status Set") 

}

blueprints's People

Contributors

henrichabrand avatar

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.