Class: Blueprint::DesignContext

Inherits:
Object
  • Object
show all
Defined in:
lib/blueprint/api/rails.rb

Overview

The default design context for logging messages, etc. Also implements uitlity methods (like send())

Instance Method Summary collapse

Instance Method Details

#send(event_type, properties = { }, message = { }) ⇒ Object

utility method for sending JSON payloads to the Anaxim servers - should never be called directly



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/blueprint/api/rails.rb', line 45

def send(event_type, properties = { }, message = { })

  # construct the base payload
  payload = {
      :header => {
          :structure_id => @structure_id,
          :properties => properties,
          :branch => {
              :name => @branch || 'master'
          },
          :eventType => event_type
      }
  }

  # merge (append) the properties hash onto the payload (properties vary per event type)
  payload.merge! message

  @conn.post do |req|
    req.url BLUEPRINT_URL_CONTEXT
    req.headers['Content-Type'] = 'application/json'
    req.headers['X-Api-Key'] = @api_key
    req.body = payload.to_json
  end

  self
end