smsfly 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 281f37c170f68433828a257d7ed0fae97d390a90
4
- data.tar.gz: 8e5d57ecdb4227bc5dfe8016c063b98652971a53
3
+ metadata.gz: 1023de6d91a5fd981d8c8f320f3fca591a5300e6
4
+ data.tar.gz: ece1def29ee14cd0dc9883176b81ecc6de09f89d
5
5
  SHA512:
6
- metadata.gz: 8e2b6db1af9a3a0d1715a9c3c2798043c615a439bbc3c9e7f776bc190e66e166d0dfdbd2c5037348b27f412c66ccb590f8f6b0d2f52e2a8e56ff5f88e1433699
7
- data.tar.gz: fdb40bebaf78effb81701805af20f964a4621a9585afbf1ea42531aa817311b3232aa7665c3a325adabc3605fb0fd14b9a6423371fa016a6655a8d50749eab2e
6
+ metadata.gz: 61c695876362691797c3392428bda3703aad45f2da9cf58b06e90eb61ff97a5f5bdee38d31f999f08dffdc1406f82dc303cd9413796c7209b8f9e4a8ac68abb3
7
+ data.tar.gz: 5e10d3fb28734394ca269d7513160eb91fdcd12ec6155d70be477c2a2fae2782d6af0bfd61c6fe5df9c0364da1469e544f30ccfa1c2875d78c5c7632a2a686f9
data/README.md CHANGED
@@ -98,6 +98,25 @@ To send a message to other numbers, use
98
98
  Smsfly.send_sms(text, recipient , description , source) # For example Smsfly.send_sms('Hello Word', '380675807873' , 'Name for Sms' , 'Alfaname')
99
99
  ```
100
100
 
101
+
102
+ Add campaignID
103
+
104
+ ```ruby
105
+ log_obj - object where we write campaignID
106
+ log_filed - campaignID feld
107
+
108
+ # for example
109
+ history = HistoryItem.new()
110
+ history.save
111
+ Smsfly.send_sms(text, recipient , description , source , {:log_obj => history, :log_filed => 'campaign_id'} )
112
+ # This write campaignID from API TO history.campaign_id
113
+ ```
114
+
115
+ ```ruby
116
+ Smsfly.send_sms(text, recipient , description , source , options = {} ) # For example Smsfly.send_sms('Hello Word', '380675807873' , 'Name for Sms' , 'Alfaname' , {:log_obj => 'Model', :log_filed => 'campaign_id'})
117
+ ```
118
+
119
+
101
120
  ## Development
102
121
 
103
122
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -130,7 +130,7 @@ XML
130
130
  end
131
131
 
132
132
 
133
- def self.send_sms(text, recipient , description , source )
133
+ def self.send_sms(text, recipient , description , source , options = {} )
134
134
  start_time = 'AUTO'
135
135
  end_time = 'AUTO'
136
136
  rate = 1
@@ -154,7 +154,51 @@ XML
154
154
  request.basic_auth login, password
155
155
  request.body = xml_string
156
156
  response = http.request(request)
157
+ p response.body
158
+ if response.body.match(/campaignID="(.*?)"/).present?
159
+ campaign = response.body.match(/campaignID="(.*?)"/)[1]
160
+ else
161
+ campaign = false
162
+ end
163
+
164
+ if campaign.present? && options[:log_obj].present? && options[:log_filed].present?
165
+ options[:log_obj].send("#{options[:log_filed]}=", campaign)
166
+ options[:log_obj].save
167
+ end
168
+ end
169
+
170
+
171
+
172
+ def self.get_status(text , options = {})
173
+
174
+ xml_string = <<XML
175
+ <?xml version="1.0" encoding="utf-8"?>
176
+ <request>
177
+ <operation>GETCAMPAIGNINFO</operation>
178
+ <message campaignID="#{text}" />
179
+ </request>
180
+ XML
181
+
182
+ full_url = "http://sms-fly.com/api/api.php"
183
+ uri = URI.parse(full_url)
184
+ headers = {'Content-Type' => "text/xml", 'Accept' => "text/xml" }
185
+ http = Net::HTTP.new(uri.host, uri.port)
186
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
187
+ request.basic_auth login, password
188
+ request.body = xml_string
189
+ response = http.request(request)
190
+ debug response.code
157
191
  debug response.body
192
+
193
+ if response.body.scan(/<state (.*?)></).present?
194
+ status_hash = Hash.new
195
+ response.body.scan(/<state (.*?)></).each do |e|
196
+ status_hash[e.first.match('status="(.*?)"')[1]] = e.first.match(' messages="(.*?)"')[1]
197
+ end
198
+ return status_hash
199
+ else
200
+ return false
201
+ end
158
202
  end
159
203
 
160
204
  end
@@ -1,3 +1,3 @@
1
1
  module Smsfly
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smsfly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii-Danovsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler