Module: Mtm

Extended by:
Mtm
Included in:
Mtm
Defined in:
lib/mtm.rb,
lib/mtm/utils.rb,
lib/mtm/version.rb

Defined Under Namespace

Classes: Mtm

Constant Summary collapse

VERSION =
"3.0.1"

Instance Method Summary collapse

Instance Method Details

#create_timecard(*args, client) ⇒ Object

Creates time card



16
17
18
19
20
21
22
23
24
25
# File 'lib/mtm/utils.rb', line 16

def create_timecard(*args, client)
  client.create!('TimeCard__c', Project__c: args[0],
                               Change__c: args[1],
                               Date__c: args[2],
                               Hours__c: args[3],
                               TeamMember__c: args[4],
                               Description__c: args[5])
  puts
  puts "Timecrad created successfully. Hour: '#{args[3]}', Project: '#{args[6]}'"
end

#parse_days_or_date(d) ⇒ Object

for date format argv



7
8
9
10
11
12
13
# File 'lib/mtm/utils.rb', line 7

def parse_days_or_date(d)
    if d.to_s =~ /^\d+$/
    d.to_i
  else
    Date.parse(d)
  end
end

#send_sms(mobile, *args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mtm/utils.rb', line 27

def send_sms(mobile, *args)
  # twilio
   = 'ACe81d15486c1f4568a9c981053bce307b'
  auth_token = 'a502db99e86340c4967cb89f0714c4ce'

  if !mobile.empty?
    # set up a client to talk to the Twilio REST API
    @t_client = Twilio::REST::Client.new , auth_token
    @t_client..sms.messages.create(
      :from => '+19788000322',
      :to => '+86' + mobile,
      :body => "Project: #{args[0]}, Hours: #{args[1]}, Description: #{args[2]}"
    )
  end
end