lib/textliner.rb
# the main interface for this gem for those that don't want to
# think of the data model underneath the API
the main interface for this gem for those that don't want to
think of the data model underneath the API
the main interface for this gem for those that don ' t want to think of the data model underneath the API
def message(customer_data, msg, &error_block)
      phone_number = customer_data[:phone_number]
      payload = payload_for(msg)
      with_customer(customer_data) do |customer|
        validate_message_if(!customer, "Customer Creation Failed :: #{customer_data}")
        validate_message_if(!customer.reachable?, "Customer Creation Failed :: #{customer_data}")
        with_conversation(customer_data) do |conversation|
          conversation ?
            Textliner::Post
              .create({
                  conversation_id: conversation.id,
                }.merge(payload)) :
            Textliner::Conversation
              .create({
                  phone_number: phone_number
                }.merge(payload))
        end
      end
    rescue Textliner::Error => e
      if error_block
        error_block.call(e)
      else
        raise e
      end 
    rescue => e
      err = Textliner::Error.new(e)
      if error_block
        error_block.call(err)
      else
        raise err
      end 
    end
def message ( customer_data , msg , & error_block ) phone_number = customer_data [ :phone_number ] payload = payload_for ( msg ) with_customer ( customer_data ) do | customer | validate_message_if ( ! customer , "Customer Creation Failed :: #{customer_data}" ) validate_message_if ( ! customer . reachable? , "Customer Creation Failed :: #{customer_data}" ) with_conversation ( customer_data ) do | conversation | conversation ? Textliner :: Post . create ( { conversation_id : conversation . id , } . merge ( payload ) ) : Textliner :: Conversation . create ( { phone_number : phone_number } . merge ( payload ) ) end end rescue Textliner :: Error => e if error_block error_block . call ( e ) else raise e end rescue => e err = Textliner :: Error . new ( e ) if error_block error_block . call ( err ) else raise err end end
the main interface for this gem for those that don't want to
think of the data model underneath the API
the main interface for this gem for those that don ' t want to think of the data model underneath the API
customer_data
<not_specific>
msg
<not_specific>
error_block
<not_specific>