Class: Unipush::Win_push

Inherits:
Object
  • Object
show all
Defined in:
lib/unipush.rb

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret) ⇒ Win_push

Returns a new instance of Win_push.



495
496
497
498
499
500
501
502
503
# File 'lib/unipush.rb', line 495

def initialize(client_id, client_secret)
  @client_id = client_id
  @client_secret = client_secret

  @auth_token_url = 'https://login.live.com/accesstoken.srf'
  @access_token = nil

  @last_error = []
end

Instance Method Details

#send_tile(content, uris) ⇒ Object



532
533
534
535
536
537
538
539
540
541
# File 'lib/unipush.rb', line 532

def send_tile(content, uris)
  headers = {
      'X-WNS-Type' => 'wns/tile',
      'Content-Type' => 'text/xml',
      'Content-Length' => content.bytesize.to_s,
      'X-WNS-RequestForStatus' => 'true'
  }

  send_messages(headers, content, uris)
end

#send_toast(text, uris) ⇒ Object



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/unipush.rb', line 506

def send_toast(text, uris)
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
    xml.toast{
      xml.visual{
        xml.binding('template'=>'toastText01') do
          xml.text_('id'=>'1') do
            xml.text text
          end
        end
      }
    }
  end

  content =  builder.to_xml

  headers = {
      'X-WNS-Type' => 'wns/toast',
      'Content-Type' => 'text/xml',
      'Content-Length' => content.bytesize.to_s,
      'X-WNS-RequestForStatus' => 'true'
  }

  send_messages(headers, content, uris)
end