<commit_before>require 'jpush'

master_secret = '2b38ce69b1de2a7fa95706ea'
app_key = 'dd1066407b044738b6479275'
client = JPush::JPushClient.new(app_key, master_secret)

logger = Logger.new(STDOUT)
#send broadcast
payload1 = JPush::PushPayload.build(
 platform: JPush::Platform.all,
 audience: JPush::Audience.all,
 notification: JPush::Notification.build(
   alert: 'alert meassage')
)
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)
 
#send winphone
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    winphone: JPush::WinphoneNotification.build(
      alert: "winphone notification alert test",
      title: "winphone notification title test",
      _open_page: "/friends.xaml",
      extras: {"key1" => "value1", "key2" => "value2"})))
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)

#send android WithExtrasMessage
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    android: JPush::AndroidNotification.build(
      alert: "android notification alert test",
      title: "android notification title test",
      builder_id: 1,
      extras: {"key1" => "value1", "key2" => "value2"})),
  message: JPush::Message.build(
    msg_content: "message content test",
    title: "message title test",
    content_type: "message content type test",
    extras: {"key1" => "value1", "key2" => "value2"})
)
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)

#send ios WithExtrasMessageANDoptions
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    android: JPush::IOSNotification.build(
      alert: "android notification alert test",
      title: "android notification title test",
      badge: 1,
      sound: "happy",
      extras: {"key1" => "value1", "key2" => "value2"})),
  message: JPush::Message.build(
    msg_content: "message content test",
    title: "message title test",
    content_type: "message content type test",
    extras: {"key1" => "value1", "key2" => "value2"}),
    options:JPush::Options.build(
    sendno: 1,
    apns_production: true))
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)
<commit_msg>add some example<commit_after>require 'jpush'

master_secret = '2b38ce69b1de2a7fa95706ea'
app_key = 'dd1066407b044738b6479275'
client = JPush::JPushClient.new(app_key, master_secret)

logger = Logger.new(STDOUT)
#send broadcast
payload1 = JPush::PushPayload.build(
 platform: JPush::Platform.all,
 audience: JPush::Audience.all,
 notification: JPush::Notification.build(
   alert: 'alert meassage')
)
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)
 
#send winphone
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    winphone: JPush::WinphoneNotification.build(
      alert: "winphone notification alert test",
      title: "winphone notification title test",
      _open_page: "/friends.xaml",
      extras: {"key1" => "value1", "key2" => "value2"})))
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)

#send android WithExtrasMessage
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    android: JPush::AndroidNotification.build(
      alert: "android notification alert test",
      title: "android notification title test",
      builder_id: 1,
      extras: {"key1" => "value1", "key2" => "value2"})),
  message: JPush::Message.build(
    msg_content: "message content test",
    title: "message title test",
    content_type: "message content type test",
    extras: {"key1" => "value1", "key2" => "value2"})
)
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)

#send ios WithExtrasMessageANDoptions
payload1 = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  audience: JPush::Audience.all,#audience: JPush::Audience.build{ _alias : "your alias"}
  notification: JPush::Notification.build(
    alert: 'alert meassage',
    android: JPush::IOSNotification.build(
      alert: "android notification alert test",
      title: "android notification title test",
      badge: 1,
      sound: "happy",
      extras: {"key1" => "value1", "key2" => "value2"})),
  message: JPush::Message.build(
    msg_content: "message content test",
    title: "message title test",
    content_type: "message content type test",
    extras: {"key1" => "value1", "key2" => "value2"}),
    options:JPush::Options.build(
    sendno: 1,
    apns_production: true))
result = client.sendPush(payload1)
logger.debug("Got result  " +  result.toJSON)
#sendByTag
payload = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  notification: JPush::Notification.build(
    alert: 'alert'),
  audience: JPush::Audience.build(
    tag: ["tag1"]))
res = client.sendPush(payload)
logger.debug("Got result  " +  res.toJSON)
#sendByTagAnd
payload = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  notification: JPush::Notification.build(
    alert: 'alert'),
  audience: JPush::Audience.build(
    tag_and: ["tag1"]))
res = client.sendPush(payload)
logger.debug("Got result  " +  res.toJSON)
#sendByAlias
payload = JPush::PushPayload.build(
  platform: JPush::Platform.all,
  notification: JPush::Notification.build(
    alert: 'alert'),
  audience: JPush::Audience.build(
    _alias: ["alias1"]))
res = client.sendPush(payload)
logger.debug("Got result  " +  res.toJSON)
{'fraction_non_alphanumeric': 0.14388972936628006, 'fraction_numerical': 0.02202050764834426, 'mean_word_length': 4.737704918032787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2607231', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1944, 'n_words': 438}