Return json payload

 +text+:: Text you want to send
 +options+:: Options you want on payload
 +env+:: Environments :prod, :dev
 +type+:: Notification type :normal, :silent, :nosound
975276
def message(text, options = {}, env = :prod, type = :normal)
      if type == :normal
        data = normal_notification(text, options)
      elsif type == :silent
        data = silent_notification(text, options)
      elsif type == :nosound
        data = nosound_notification(text, options)
      end
      return dev_json(data) if env == :dev
      prod_json(data)
    end
33950
def post_message(text, options = {})
      payload = {
        username: @options['name'],
        channel:  @options['channel'],
        text:     text,
        as_user:  true
      }.merge(options)

      unless direct_message?(payload[:channel])
        payload[:channel] = enforce_leading_hash(payload[:channel])
        @api.join(payload[:channel])
      end

      @api.post_message(payload)
      return nil # be quiet in webhook reply
    end
595379
def as_json(opts={})
      atts = {
        'id'                => id,
        'color'             => color,
        'status'            => display_status,
        'percent_complete'  => percent_complete,
        'work_units'        => work_units.count,
        'time_taken'        => time_taken
      }
      atts['outputs'] = JSON.parse(outputs) if outputs
      atts['email']   = email               if email
      atts
    end
1368334
def serialize(self):
        

        if self.response is not None:
            return {'messaging_type': 'RESPONSE'}

        if self.update is not None:
            return {'messaging_type': 'UPDATE'}

        if self.tag is not None:
            return {
                'messaging_type': 'MESSAGE_TAG',
                'tag': self.tag.value,
            }

        if self.subscription is not None:
            return {'messaging_type': 'NON_PROMOTIONAL_SUBSCRIPTION'}
542537
def encode_notifications(tokens, notifications):
  
  
  fmt = "!BH32sH%ds"
  structify = lambda t, p: struct.pack(fmt % len(p), 0, 32, t, len(p), p)
  binaryify = lambda t: t.decode('hex')
  if type(notifications) is dict and type(tokens) in (str, unicode):
    tokens, notifications = ([tokens], [notifications])
  if type(notifications) is list and type(tokens) is list:
    return ''.join(map(lambda y: structify(*y), ((binaryify(t), json.dumps(p, separators=(',',':'), ensure_ascii=False).encode('utf-8'))
                                    for t, p in zip(tokens, notifications))))
118275
def _get_text(self):
        
        device = self._get_device()
        if device is None:
            return (UNKNOWN_DEVICE, self.py3.COLOR_BAD)

        if not device["isReachable"] or not device["isTrusted"]:
            return (
                self.py3.safe_format(
                    self.format_disconnected, {"name": device["name"]}
                ),
                self.py3.COLOR_BAD,
            )

        battery = self._get_battery()
        (charge, bat_status, color) = self._get_battery_status(battery)

        notif = self._get_notifications()
        (notif_size, notif_status) = self._get_notifications_status(notif)

        return (
            self.py3.safe_format(
                self.format,
                dict(
                    name=device["name"],
                    charge=charge,
                    bat_status=bat_status,
                    notif_size=notif_size,
                    notif_status=notif_status,
                ),
            ),
            color,
        )
319096
def version
      send_message!(Protocol::Device::GetVersion.new,
         wait_for: Protocol::Device::StateVersion) do |payload|
        {
          vendor: payload.vendor,
          product: payload.product,
          version: payload.version
        }
      end
    end
1347279
function data( opts ) {
	var out = {};
	out.github_token = opts.token;
	return JSON.stringify( out );
}
782261
function emit (msg, done) {
    var raw_data = [
      {source: 'demo-plugin', payload: {val: 1, tag: 'foo'}},
      {val: 2, tag: 'foo'}
    ]

    done(null, raw_data)
  }
1137932
def generate_payload
        payload = {}
        payload[:channel]     = self.channel    unless self.channel.nil?
        payload[:username]    = self.username   unless self.username.nil?
        payload[:icon_url]    = self.icon_url   unless self.icon_url.nil?
        payload[:icon_emoji]  = self.icon_emoji unless self.icon_emoji.nil?
        payload[:text]        = self.text       unless self.text.nil?
        payload[:attachments] = self.attachments unless self.attachments.empty?

        payload
    end
650222
def dispatch(env)
      return [500, {'Content-Type' => 'text/plain'}, ["Server Not Ready"]] if @booting

      begin
        new_env = plugin_before_dispatch(env)
        plugin_after_dispatch(new_env, do_dispatch(new_env))
      rescue Exception => e
        bt = e.backtrace.join("\n")
        [500, {'Content-Type' => 'text/plain'}, ["Exception: #{e}\n\n#{bt}"]]
      end
    end
59191
def as_json(*args)
      request = construct_request_hash
      request[:context] = s(context)
      request[:local_variables] = local_variables if local_variables

      {
        api_key: s(api_key),
        notifier: NOTIFIER,
        error: {
          token: id,
          class: s(error_class),
          message: s(error_message),
          backtrace: s(parse_backtrace(backtrace)),
          fingerprint: fingerprint_hash,
          tags: s(tags),
          causes: s(causes)
        },
        request: request,
        server: {
          project_root: s(config[:root]),
          revision: s(config[:revision]),
          environment_name: s(config[:env]),
          hostname: s(config[:hostname]),
          stats: stats,
          time: now,
          pid: pid
        }
      }
    end
543222
function Notification (payload) {
  this.encoding = "utf8";
  this.payload = {};
  this.compiled = false;

  this.aps = {};
  this.expiry = 0;
  this.priority = 10;

  if (payload) {
    for(let key in payload) {
      if (payload.hasOwnProperty(key)) {
        this[key] = payload[key];
      }
    }
  }
}
841037
async def postback_send(msg: BaseMessage, platform: Platform) -> Response:
    

    await platform.inject_message(msg)

    return json_response({
        'status': 'ok',
    })
1311074
def as_json(options = {})
      {}.tap do |result|
        result[:body] = @body unless @body.nil?
        result[:headers] = @headers unless @headers.nil?
        result[:status] = @status unless @status.nil?
      end
    end
1206833
def slack_notify(self):
        """"""
        utils.banner("Sending slack notification")

        if self.env.startswith("prod"):
            notify = slacknotify.SlackNotification(app=self.app, env=self.env, prop_path=self.json_path)
            notify.post_message()
        else:
            LOG.info("No slack message sent, not production environment")
144587
def send_messages(messages, opts = {})
      data, _status_code, _headers = send_messages_with_http_info(messages, opts)
      return data
    end