module BitrixWebhook::TASK::ITEM

Public Class Methods

add(options = {}) click to toggle source
# File lib/bitrix_webhook/task/item.rb, line 15
def self.add(options = {})
  options = config.merge(options)
  query_params = {
      fields: {
          TITLE: options[:title],
          RESPONSIBLE_ID: options[:responsible_id],
          DEADLINE: (DateTime.now + 1.day).strftime("%FT%T%:z"),
          UF_CRM_TASK: ["L_#{options[:crm_user_id]}"]
      },
  }.to_query
  post_url = base_url('add').to_s + query_params

  begin
    JSON.parse(HTTP.post(post_url).body)
  rescue => e
    {error:e}.to_json
  end
end
base_url(method) click to toggle source
# File lib/bitrix_webhook/task/item.rb, line 11
def self.base_url(method)
  "https://#{BitrixWebhook.bitrix24_url}/rest/#{BitrixWebhook.webhook_user}/#{ BitrixWebhook.hook}/task.item.#{method}?"
end
config() click to toggle source
# File lib/bitrix_webhook/task/item.rb, line 5
def self.config
  {
      responsible_id: BitrixWebhook.webhook_user
  }
end
getdata(task_id) click to toggle source
# File lib/bitrix_webhook/task/item.rb, line 53
def self.getdata(task_id)
  query_params = {
      TASKID: task_id
  }.to_query
  post_url = base_url('getdata').to_s + query_params

  begin
    JSON.parse(HTTP.post(post_url).body)
  rescue => e
    {error:e}.to_json
  end
end
raw_add(options = {}) click to toggle source
# File lib/bitrix_webhook/task/item.rb, line 34
def self.raw_add(options = {})
  options = config.merge(options)
  fields = {}
  options.each_pair do |k,v|
    fields.merge!({k.upcase => v})
  end
  query_params = {
      fields: fields,
  }.to_query
  post_url = base_url('add').to_s + query_params

  begin
    JSON.parse(HTTP.post(post_url).body)
  rescue => e
    {error:e}.to_json
  end
end