├── .gitignore ├── Gemfile ├── LICENSE.md ├── README.md ├── Rakefile ├── bulutfon_sdk.gemspec ├── conf └── cacert.pem ├── examples ├── examples.rb ├── pdf-sample.pdf └── test.wav ├── lib ├── bulutfon_sdk.rb └── bulutfon_sdk │ ├── hash.rb │ ├── helpers │ └── data_helper.rb │ ├── rest │ ├── announcement.rb │ ├── automatic_call.rb │ ├── base_request.rb │ ├── bulutfon.rb │ ├── call_record.rb │ ├── cdr.rb │ ├── did.rb │ ├── errors.rb │ ├── extension.rb │ ├── group.rb │ ├── incoming_fax.rb │ ├── message.rb │ ├── message_title.rb │ └── outgoing_fax.rb │ ├── util.rb │ ├── util │ └── client_config.rb │ └── version.rb └── spec ├── bulutfon_sdk_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *~ 11 | .* 12 | pkg/* 13 | doc/* 14 | Gemfile.lock 15 | *.gem 16 | bin 17 | docs/_build 18 | .DS_Store -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in bulutfon_sdk.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015 Bulutfon 2 | 3 | The MIT License (MIT) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bulutfon Ruby SDK 2 | 3 | [![Gem Version](https://badge.fury.io/rb/bulutfon_sdk.svg)](https://badge.fury.io/rb/bulutfon_sdk) 4 | 5 | * [API Dokümantasyonu](https://github.com/bulutfon/documents/tree/master/API) 6 | * [Örnek Kodlar](https://github.com/bulutfon/ruby-sdk/tree/master/examples) 7 | 8 | # ÖNEMLİ: Bu SDK APIv1 uyumludur. 9 | 10 | ## Kullanım 11 | 12 | ### Kurulum 13 | 14 | Gemfile dosyanıza şu satırı ekleyiniz 15 | 16 | ``` ruby 17 | gem 'bulutfon_sdk' 18 | ``` 19 | 20 | Bu satırı ekledikten sonra, 21 | 22 | ``` bash 23 | bundle install 24 | ``` 25 | komutunu koşarak gerekli paketleri yükledikten sonra BulutfonSDK'yı kullanmaya başlayabilirsiniz. 26 | 27 | ### Master Token ile 28 | 29 | ```ruby 30 | require 'bulutfon_sdk' 31 | 32 | token = 'your_token' 33 | bulutfon = BulutfonSDK::REST::Bulutfon.new(token) 34 | ``` 35 | 36 | ## İşlevler 37 | 38 | ### Kullanıcı bilgilerine erişme 39 | 40 | SDK ile Kullanıcı bilgileriniz, panel bilgileriniz ve kalan kredinize erişebilirsiniz. 41 | Bunun için 42 | 43 | ``` ruby 44 | puts bulutfon.details 45 | ``` 46 | 47 | methodunu kullanabilirsiniz. 48 | 49 | ### Telefon numaraları ve telefon numara detaylarına erişme 50 | 51 | Bunun için; 52 | 53 | ```ruby 54 | # Santral listesine erişir 55 | puts bulutfon.dids.all 56 | # Id'si verilen santral detayını döndürür 57 | puts bulutfon.dids.get(1) 58 | ``` 59 | 60 | methodlarını kullanabilirsiniz. 61 | 62 | ### Dahililere ve dahili detaylarına erişme, dahili oluşturma, güncelleme ve silme 63 | 64 | Bunun için; 65 | 66 | ```ruby 67 | # Dahili listesine erişir 68 | puts bulutfon.extensions.all 69 | # Id'si verilen dahili detayını döndürür 70 | puts bulutfon.extensions.get(1) 71 | # Verilen parametrelere göre yeni dahili oluşturur. 72 | params = { 73 | full_name: 'Deneme', 74 | email: 'deneme@deneme.com', 75 | did: '905xxxxxxxxx', 76 | number: 9999, 77 | redirection_type: 'NONE', 78 | destination_type: 'EXTENSION', 79 | destination_number: '905xxxxxxxxx', 80 | 'acl[]' => [ 'domestic', 'gsm', 'international'] 81 | } 82 | puts bulutfon.extensions.create(params) 83 | # Verilen parametrelere göre dahiliyi günceller 84 | params = { 85 | full_name: 'Deneme Deneme', 86 | 'acl[]' => [ 'domestic', 'gsm'] 87 | } 88 | puts bulutfon.extensions.update(1, params) 89 | # Dahiliyi siler 90 | puts bulutfon.extensions.delete(1) 91 | ``` 92 | 93 | methodlarını kullanabilirsiniz. 94 | 95 | ### Gruplara ve grup detaylarına erişme 96 | 97 | Bunun için; 98 | 99 | ```ruby 100 | # Grup listesine erişir 101 | puts bulutfon.groups.all 102 | # Id'si verilen grup detayını döndürür 103 | puts bulutfon.groups.get(1) 104 | ``` 105 | 106 | methodlarını kullanabilirsiniz. 107 | 108 | ### Arama kayıtlarına ve arama detaylarına erişme ve ses kayıtlarını indirme 109 | 110 | Bunun için; 111 | 112 | ```ruby 113 | # Cdr listesine erişir 114 | puts bulutfon.cdrs.all 115 | # Cdr listesine sayfalama yaparak erişir 116 | puts bulutfon.cdrs.all({page: 1, limit: 3}) 117 | # Uuid'si verilen cdr detayını döndürür 118 | puts bulutfon.cdrs.get('uuid') 119 | # Uuid'si verilen arama kaydinin detaylarini getir 120 | puts bulutfon.call_records.get('uuid') 121 | # Uuid'si verilen ses kaydını indir 122 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_uuid.ogg" 123 | puts bulutfon.call_records.save('uuid', save_path) 124 | ``` 125 | 126 | methodlarını kullanabilirsiniz. 127 | 128 | ### Gelen fakslara erişme ve faks dosyasını indirme 129 | 130 | Bunun için; 131 | 132 | ```ruby 133 | # Gelen faksları listeler 134 | puts bulutfon.incoming_faxes.all 135 | # Uuid'si verilen gelen faksın detayları 136 | puts bulutfon.incoming_faxes.get('uuid') 137 | # Uuid'si verilen gelen faksı indir 138 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_uuid.tiff" 139 | puts bulutfon.incoming_faxes.save('uuid', save_path) 140 | ``` 141 | 142 | methodlarını kullanabilirsiniz. 143 | 144 | ### Giden fakslara erişme ve faks gönderme 145 | 146 | Bunun için; 147 | 148 | ```ruby 149 | # Giden faksları listeler 150 | puts bulutfon.outgoing_faxes.all 151 | # Id'si verilen giden faks detayları 152 | puts bulutfon.outgoing_faxes.get(1) 153 | # Faks gönderme işlemi 154 | file = "#{File.expand_path(File.dirname(__FILE__))}/pdf-sample.pdf" 155 | params = { 156 | title: 'Deneme', 157 | receivers: '905xxxxxxxxx', 158 | did: '905xxxxxxxxx', 159 | attachment: file 160 | } 161 | puts bulutfon.outgoing_faxes.create(params) 162 | ``` 163 | 164 | methodlarını kullanabilirsiniz. 165 | 166 | ### Ses Dosyalarını listeleme ve indirme, oluşturma ve silme 167 | 168 | Bunun için; 169 | 170 | ```ruby 171 | # Ses Dosyalarını listeler 172 | puts bulutfon.announcements.all 173 | # Id'si verilen ses dosyasının detayları 174 | puts bulutfon.announcements.get(1) 175 | # Ses dosyası oluşturma 176 | file = "#{File.expand_path(File.dirname(__FILE__))}/test.wav" 177 | params = { 178 | name: 'Deneme', 179 | announcement: file 180 | } 181 | puts bulutfon.announcements.create(params) 182 | # Id'si verilen ses dosyasını indirme işlemi 183 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_test.wav" 184 | puts bulutfon.announcements.save(1, save_path) 185 | # Id'si verilen ses dosyasını silme 186 | puts bulutfon.announcements.delete(1) 187 | ``` 188 | 189 | methodlarını kullanabilirsiniz. 190 | 191 | ### Otomatik Aramaları listeleme ve oluşturma 192 | 193 | Bunun için; 194 | 195 | ```ruby 196 | puts bulutfon.automatic_calls.all # Otomatik aramaları listeler 197 | puts bulutfon.automatic_calls.get(1) # Id'si verien otomatik arama detaylarını görüntüler 198 | # Automatic call oluşturur ve oluşturmadan sonra receivers numaraları aranır 199 | params = { 200 | title: 'Automatic call after creation', 201 | receivers: '905xxxxxxxxx', 202 | did: '905xxxxxxxxx', 203 | announcement_id: 1 204 | } 205 | puts bulutfon.automatic_calls.create(params) 206 | # Zaman planlı automatic call oluşturulur ve oluşturmadan sonra receivers numaraları 207 | # perşembe günü saat 10:15 ile 12:00 arasında aranır 208 | params = { 209 | title: 'Time planned call', 210 | receivers: '905xxxxxxxxx', 211 | did: '905xxxxxxxxx', 212 | announcement_id: 1, 213 | mon_active: false, 214 | tue_active: false, 215 | wed_active: false, 216 | thu_active: true, 217 | thu_start: '10:15', 218 | thu_finish: '12:00', 219 | fri_active: false, 220 | sat_active: false, 221 | sun_active: false, 222 | hours_active: true 223 | } 224 | puts bulutfon.automatic_calls.create(params) 225 | ``` 226 | 227 | methodlarını kullanabilirsiniz. 228 | 229 | ### Sms Başlıklarını Listeleme 230 | 231 | Bunun için; 232 | 233 | ```ruby 234 | # Panelden oluşturduğunuz sms başlıklarını listeler 235 | puts bulutfon.message_titles.all 236 | ``` 237 | 238 | methodlarını kullanabilirsiniz. 239 | 240 | ### Mesajları Listeleme ve Mesaj Gönderme 241 | 242 | Bunun için; 243 | 244 | ```ruby 245 | # Gönderilen mesajları listeler 246 | puts bulutfon.messages.all 247 | # Gönderilen mesajları sayfalama yaparak listeler 248 | puts bulutfon.messages.all({page: 1, limit: 3 }) 249 | # Id'si verilen mesaj detaylarını döndürür 250 | puts bulutfon.messages.get(1) 251 | # Yeni mesaj gönderme işlemi 252 | params = { 253 | title: 'CONFIRMED_MESSAGE_TITLE', 254 | content: 'Test Message', 255 | receivers: '905xxxxxxxxx' 256 | } 257 | puts bulutfon.messages.create(params) 258 | # Çoklu alıcılı mesaj gönderme işlemi 259 | params_multiple = { 260 | title: 'CONFIRMED_MESSAGE_TITLE', 261 | content: 'Multiple Message', 262 | receivers: '905xxxxxxxxx,905xxxxxxxxx' 263 | } 264 | puts bulutfon.messages.create(params_multiple) 265 | # Zaman planlı mesaj gönderme işlemi 266 | params = { 267 | title: 'CONFIRMED_MESSAGE_TITLE', 268 | content: 'Planned message example', 269 | receivers: '905xxxxxxxxx', 270 | is_future_sms: true, 271 | send_date: '16/12/2015 10:00' 272 | } 273 | puts bulutfon.messages.create(params) 274 | ``` 275 | 276 | methodlarını kullanabilirsiniz. 277 | 278 | Örnek kullanımları görmek için ve erişebileceğiniz değişkenler için [örnek kodlarımızı](https://github.com/bulutfon/ruby-sdk/tree/master/examples) inceleyebilirsiniz. 279 | 280 | ## Hash cevapları OpenStruct objesine dönüştürme 281 | 282 | ### Hesap 283 | ```ruby 284 | bulutfon = BulutfonSDK::REST::Bulutfon.new(token) 285 | # Hesap detaylarını hash olarak gösterir 286 | puts bulutfon.details 287 | # Örnek bir hesap detayları sonucu 288 | details = { 289 | 'user' =>{ 290 | 'email' => 'test@bulutfon.com', 'name' => 'BULUTFON', 'gsm' => 'XXXXXXXXXXXX' 291 | }, 292 | 'pbx' =>{ 293 | 'name' => 'test', 'url' => 'test.com', 'state' => 'CONFIRMED', 'package' => 'ENTERPRISE', 'customer_type' => 'CORPORATE' 294 | }, 295 | 'credit' =>{ 296 | 'balance' => '10.00', 'sms_credit' => 0 297 | } 298 | } 299 | # to_obj bizim hash sonuçları için tanımladığımız yardımcı metodumuz 300 | detail_object = bulutfon.details.to_obj 301 | puts detail_object 302 | # Object örneği 303 | =begin 304 | #, 306 | pbx=#, 307 | credit=#> 308 | =end 309 | # Obje üzerinden alanlara şu şekilde ulaşabilirsiniz 310 | puts detail_object.user.email 311 | puts detail_object.user.name 312 | puts detail_object.pbx.name 313 | puts detail_object.pbx.url 314 | puts detail_object.credit.balance 315 | puts detail_object.credit.sms_credit 316 | ``` 317 | 318 | ### Gruplar için örnek 319 | ```ruby 320 | group_sdk = BulutfonSDK::REST::Group.new(token) 321 | obj_result = group_sdk.all.to_obj 322 | =begin 323 | #, 326 | #, 327 | # 328 | ]> 329 | =end 330 | obj_result.groups.each do |group| 331 | puts group.name 332 | end 333 | ``` 334 | 335 | ##Credits 336 | * ruby_sdk is maintained by [Lab2023](http://lab2023.com/) & [Bulutfon](https://www.bulutfon.com/) 337 | * Thank you to all the contributors! 338 | * The names and logos for Bulutfon are trademarks of Bulutfon 339 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /bulutfon_sdk.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'bulutfon_sdk/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'bulutfon_sdk' 8 | spec.version = BulutfonSDK::VERSION 9 | spec.authors = ['Ismail Akbudak'] 10 | spec.email = ['ismail.akbudak@lab2023.com'] 11 | 12 | spec.summary = %q{Bulutfon Ruby SDK.} 13 | spec.description = %q{Bulutfon API SDK for ruby & ruby on rails.} 14 | spec.homepage = 'https://github.com/bulutfon/ruby-sdk' 15 | spec.extra_rdoc_files = ['README.md', 'LICENSE.md'] 16 | spec.license = 'MIT' 17 | 18 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 19 | spec.bindir = 'exe' 20 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 21 | spec.require_paths = ['lib'] 22 | 23 | spec.add_runtime_dependency 'multi_json', '~> 1.11', '>= 1.11.0' 24 | spec.add_dependency('mime-types', '~> 1.25') 25 | spec.add_development_dependency 'bundler', '~> 1.10' 26 | spec.add_development_dependency 'rake', '~> 10.0' 27 | spec.add_development_dependency 'rspec', '~> 0' 28 | end 29 | -------------------------------------------------------------------------------- /conf/cacert.pem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bulutfon/ruby-sdk/a6b70b6e5ea15ab40b797726ddab993a9f95f5b7/conf/cacert.pem -------------------------------------------------------------------------------- /examples/examples.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk' 2 | 3 | token = 'your_token' 4 | 5 | # Account 6 | # ------------------------------------------------------------- 7 | bulutfon = BulutfonSDK::REST::Bulutfon.new(token) 8 | # Get account details 9 | puts bulutfon.details 10 | # BulutfonSDK::REST::Message object 11 | puts bulutfon.messages 12 | # BulutfonSDK::REST::MessageTitle object 13 | puts bulutfon.message_titles 14 | # BulutfonSDK::REST::Did object 15 | puts bulutfon.dids 16 | # BulutfonSDK::REST::Extension object 17 | puts bulutfon.extensions 18 | # BulutfonSDK::REST::Group object 19 | puts bulutfon.groups 20 | # BulutfonSDK::REST::Cdr object 21 | puts bulutfon.cdrs 22 | # BulutfonSDK::REST::CallRecord object 23 | puts bulutfon.call_records 24 | # BulutfonSDK::REST::IncomingFax object 25 | puts bulutfon.incoming_faxes 26 | # BulutfonSDK::REST::OutgoingFax object 27 | puts bulutfon.outgoing_faxes 28 | # BulutfonSDK::REST::Announcement object 29 | puts bulutfon.announcements 30 | # BulutfonSDK::REST::AutomaticCall object 31 | puts bulutfon.automatic_calls 32 | 33 | # Dids 34 | # ------------------------------------------------------------- 35 | did = BulutfonSDK::REST::Did.new(token) 36 | # Get dids 37 | puts did.all 38 | # Get did with id 39 | puts did.get(1) 40 | 41 | # Extensions 42 | # ------------------------------------------------------------- 43 | extension = BulutfonSDK::REST::Extension.new(token) 44 | # Get extensions 45 | puts extension.all 46 | # Get extension with id 47 | puts extension.get(1) 48 | # Create extension 49 | params = { 50 | full_name: 'Deneme', 51 | email: 'deneme@deneme.com', 52 | did: '905xxxxxxxxx', 53 | number: 9999, 54 | redirection_type: 'NONE', 55 | destination_type: 'EXTENSION', 56 | destination_number: '905xxxxxxxxx', 57 | 'acl[]' => [ 'domestic', 'gsm', 'international'] 58 | } 59 | puts extension.create(params) 60 | # Update extension 61 | params = { 62 | full_name: 'Deneme Deneme', 63 | 'acl[]' => [ 'domestic', 'gsm'] 64 | } 65 | puts extension.update(1, params) 66 | # Delete extension 67 | puts extension.delete(1) 68 | 69 | # Groups 70 | # ------------------------------------------------------------- 71 | group = BulutfonSDK::REST::Group.new(token) 72 | # Get groups 73 | puts group.all 74 | # Get group with id 75 | puts group.get(1) 76 | 77 | # Cdrs 78 | # ------------------------------------------------------------- 79 | cdr = BulutfonSDK::REST::Cdr.new(token) 80 | # Get cdrs 81 | puts cdr.all 82 | # Get cdrs with pagination 83 | puts cdr.all({page: 1, limit: 1}) 84 | # Get cdr with uuid 85 | puts cdr.get('uuid') 86 | 87 | # Call Records 88 | # ------------------------------------------------------------- 89 | call_record = BulutfonSDK::REST::CallRecord.new(token) 90 | # Get call_record detail with uuid 91 | puts call_record.get('uuid') 92 | # Save call record to save_path with uuid 93 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_uuid.ogg" 94 | puts call_record.save('uuid', save_path) 95 | 96 | # Incoming Faxes 97 | # ------------------------------------------------------------- 98 | incoming_fax = BulutfonSDK::REST::IncomingFax.new(token) 99 | # Get incoming faxes 100 | puts incoming_fax.all 101 | # Get incoming fax with uuid 102 | puts incoming_fax.get('uuid') 103 | # Save incoming fax to save_path with uuid 104 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_uuid.tiff" 105 | puts incoming_fax.save('uuid', save_path) 106 | 107 | # Outgoing Faxes 108 | # ------------------------------------------------------------- 109 | outgoing_fax = BulutfonSDK::REST::OutgoingFax.new(token) 110 | # Get outgoing faxes 111 | puts outgoing_fax.all 112 | # Get outgoing fax with id 113 | puts outgoing_fax.get(1) 114 | # Create outgoing faxes 115 | file = "#{File.expand_path(File.dirname(__FILE__))}/pdf-sample.pdf" 116 | params = { 117 | title: 'Deneme', 118 | receivers: '905xxxxxxxxx', 119 | did: '905xxxxxxxxx', 120 | attachment: file 121 | } 122 | puts outgoing_fax.create(params) 123 | 124 | # Announcements 125 | # ------------------------------------------------------------- 126 | announcement = BulutfonSDK::REST::Announcement.new(token) 127 | # Get announcements 128 | puts announcement.all 129 | # Get announcement with id 130 | puts announcement.get(1) 131 | # Create announcement 132 | file = "#{File.expand_path(File.dirname(__FILE__))}/test.wav" 133 | params = { 134 | name: 'Deneme', 135 | announcement: file 136 | } 137 | puts announcement.create(params) 138 | # Save announcement file to save_path with id 139 | save_path = "#{File.expand_path(File.dirname(__FILE__))}/save_test.wav" 140 | puts announcement.save(1, save_path) 141 | # Delete announcement with id 142 | puts announcement.delete(1) 143 | 144 | # Automatic Calls 145 | # ------------------------------------------------------------- 146 | automatic_call = BulutfonSDK::REST::AutomaticCall.new(token) 147 | # Get automatic calls 148 | puts automatic_call.all 149 | # Get automatic call with id 150 | puts automatic_call.get(1) 151 | # Create automatic call, after creation receivers will call 152 | params = { 153 | title: 'Automatic call after creation', 154 | receivers: '905xxxxxxxxx', 155 | did: '905xxxxxxxxx', 156 | announcement_id: 1 157 | } 158 | puts automatic_call.create(params) 159 | # Create time planned automatic call, in this params receivers will be calling on thursday between 10:15, 12:00 160 | params = { 161 | title: 'Time planned call', 162 | receivers: '905xxxxxxxxx', 163 | did: '905xxxxxxxxx', 164 | announcement_id: 1, 165 | mon_active: false, 166 | tue_active: false, 167 | wed_active: false, 168 | thu_active: true, 169 | thu_start: '10:15', 170 | thu_finish: '12:00', 171 | fri_active: false, 172 | sat_active: false, 173 | sun_active: false, 174 | hours_active: true 175 | } 176 | puts automatic_call.create(params) 177 | 178 | # Message Titles 179 | # ------------------------------------------------------------- 180 | message_title = BulutfonSDK::REST::MessageTitle.new(token) 181 | # Get message titles 182 | puts message_title.all 183 | 184 | # Messages 185 | # ------------------------------------------------------------- 186 | message = BulutfonSDK::REST::Message.new(token) 187 | # Get messages 188 | puts message.all 189 | # Get messages with pagination 190 | puts message.all({page: 1, limit: 3 }) 191 | # Get message with id 192 | puts message.get(1) 193 | # Create message 194 | params = { 195 | title: 'CONFIRMED_MESSAGE_TITLE', 196 | content: 'Test Message', 197 | receivers: '905xxxxxxxxx' 198 | } 199 | puts message.create(params) 200 | # Create message for multiple receiver 201 | params_multiple = { 202 | title: 'CONFIRMED_MESSAGE_TITLE', 203 | content: 'Multiple Message', 204 | receivers: '905xxxxxxxxx,905xxxxxxxxx' 205 | } 206 | puts message.create(params_multiple) 207 | # Create time planned message 208 | params = { 209 | title: 'CONFIRMED_MESSAGE_TITLE', 210 | content: 'Planned message example', 211 | receivers: '905xxxxxxxxx', 212 | is_future_sms: true, 213 | send_date: '16/12/2015 10:00' 214 | } 215 | puts message.create(params) 216 | 217 | ############################################## 218 | # Create OpenStruct object from hash 219 | ############################################## 220 | 221 | # Account 222 | # ------------------------------------------------------------- 223 | bulutfon = BulutfonSDK::REST::Bulutfon.new(token) 224 | # Get account details 225 | puts bulutfon.details 226 | 227 | # Details result is like below 228 | =begin 229 | details = { 230 | 'user' =>{ 231 | 'email' => 'test@bulutfon.com', 'name' => 'BULUTFON', 'gsm' => 'XXXXXXXXXXXX' 232 | }, 233 | 'pbx' =>{ 234 | 'name' => 'test', 'url' => 'test.com', 'state' => 'CONFIRMED', 'package' => 'ENTERPRISE', 'customer_type' => 'CORPORATE' 235 | }, 236 | 'credit' =>{ 237 | 'balance' => '10.00', 'sms_credit' => 0 238 | } 239 | } 240 | =end 241 | 242 | # to_obj is our helper method for hashes 243 | detail_object = bulutfon.details.to_obj 244 | puts detail_object 245 | 246 | # Object Example 247 | =begin 248 | #, 250 | pbx=#, 251 | credit=#> 252 | =end 253 | 254 | # You can access fields 255 | puts detail_object.user.email 256 | puts detail_object.user.name 257 | puts detail_object.pbx.name 258 | puts detail_object.pbx.url 259 | puts detail_object.credit.balance 260 | puts detail_object.credit.sms_credit 261 | 262 | # Groups 263 | # ------------------------------------------------------------- 264 | group_sdk = BulutfonSDK::REST::Group.new(token) 265 | obj_result = group_sdk.all.to_obj 266 | =begin 267 | #, 270 | #, 271 | # 272 | ]> 273 | =end 274 | obj_result.groups.each do |group| 275 | puts group.name 276 | end -------------------------------------------------------------------------------- /examples/pdf-sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bulutfon/ruby-sdk/a6b70b6e5ea15ab40b797726ddab993a9f95f5b7/examples/pdf-sample.pdf -------------------------------------------------------------------------------- /examples/test.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bulutfon/ruby-sdk/a6b70b6e5ea15ab40b797726ddab993a9f95f5b7/examples/test.wav -------------------------------------------------------------------------------- /lib/bulutfon_sdk.rb: -------------------------------------------------------------------------------- 1 | require 'net/http' 2 | require 'net/https' 3 | require 'multi_json' 4 | require 'cgi' 5 | require 'openssl' 6 | require 'open3' 7 | require 'mime/types' 8 | require 'base64' 9 | require 'ostruct' 10 | 11 | require 'bulutfon_sdk/version' unless defined?(BulutfonSDK::VERSION) 12 | require 'bulutfon_sdk/util' 13 | require 'bulutfon_sdk/helpers/data_helper' 14 | require 'bulutfon_sdk/hash' 15 | require 'bulutfon_sdk/rest/bulutfon' 16 | require 'bulutfon_sdk/rest/message' 17 | require 'bulutfon_sdk/rest/did' 18 | require 'bulutfon_sdk/rest/group' 19 | require 'bulutfon_sdk/rest/cdr' 20 | require 'bulutfon_sdk/rest/announcement' 21 | require 'bulutfon_sdk/rest/automatic_call' 22 | require 'bulutfon_sdk/rest/call_record' 23 | require 'bulutfon_sdk/rest/incoming_fax' 24 | require 'bulutfon_sdk/rest/outgoing_fax' 25 | require 'bulutfon_sdk/rest/extension' 26 | require 'bulutfon_sdk/rest/message_title' 27 | require 'bulutfon_sdk/util/client_config' 28 | require 'bulutfon_sdk/rest/errors' 29 | 30 | include BulutfonSDK::Helpers::DataHelper 31 | 32 | module BulutfonSDK 33 | # Your code goes here... 34 | end 35 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/hash.rb: -------------------------------------------------------------------------------- 1 | class Hash 2 | def to_obj 3 | convert_to_obj self 4 | end 5 | end -------------------------------------------------------------------------------- /lib/bulutfon_sdk/helpers/data_helper.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | module Helpers 3 | module DataHelper 4 | 5 | ## 6 | # Convert hash to object 7 | def convert_to_obj(hash) 8 | open_struct = OpenStruct.new 9 | set_open_struct_variables( open_struct, hash ) 10 | open_struct 11 | end 12 | 13 | ## 14 | # Set hash variable to open_struct 15 | # Recursive method for hash values 16 | def set_open_struct_variables(open_struct, hash) 17 | hash.each do |key,value| 18 | if value.is_a? Hash 19 | # create new open struct value 20 | new_open_struct = OpenStruct.new 21 | open_struct.send("#{key}=", new_open_struct) 22 | set_open_struct_variables(new_open_struct, value) 23 | elsif value.is_a? Array 24 | open_struct.send("#{key}=", value) 25 | value.each_with_index do |val, index| 26 | if val.is_a? Hash 27 | # create new open struct value 28 | new_open_struct = OpenStruct.new 29 | # set array index value variable 30 | value[index] = new_open_struct 31 | set_open_struct_variables(new_open_struct, val) 32 | else 33 | # Do nothing 34 | # value[index] = val 35 | end 36 | end 37 | else 38 | open_struct.send("#{key}=", value) 39 | end 40 | end 41 | end 42 | 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/announcement.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Announcement < BaseRequest 6 | 7 | include BulutfonSDK::Util 8 | 9 | def initialize(*args) 10 | super(*args) 11 | @resource = 'announcements' 12 | end 13 | 14 | def all( params = {} ) 15 | prepare_request( 'get', @resource,params) 16 | end 17 | 18 | def get( id ) 19 | uri = prepare_uri("#{@resource}/#{id}") 20 | { download_path: uri.to_s } 21 | end 22 | 23 | def save( id, save_path) 24 | save_file( 'get', "#{@resource}/#{id}", save_path) 25 | end 26 | 27 | def create(params) 28 | prepare_atachment(params) 29 | prepare_request( 'post', @resource, params) 30 | end 31 | 32 | def delete(id) 33 | prepare_request( 'delete', "#{@resource}/#{id}") 34 | end 35 | 36 | private 37 | 38 | def prepare_atachment(params) 39 | file = params[:announcement] 40 | basename = File.basename file 41 | type = file_content_type file 42 | content = File.read(file) 43 | base_64_data = Base64.strict_encode64(content) 44 | params[:announcement] = "data:#{type};name:#{basename};base64:#{base_64_data}" 45 | end 46 | 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/automatic_call.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class AutomaticCall < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'automatic-calls' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource, params) 14 | end 15 | 16 | def get( id ) 17 | prepare_request( 'get', "#{@resource}/#{id}") 18 | end 19 | 20 | def create(params) 21 | prepare_request( 'post', @resource, params) 22 | end 23 | 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/base_request.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | module REST 3 | class BaseRequest 4 | 5 | HTTP_HEADERS = { 6 | 'Accept' => 'application/json', 7 | 'Accept-Charset' => 'utf-8', 8 | 'User-Agent' => "bulutfon_sdk/#{BulutfonSDK::VERSION}" " (#{RUBY_ENGINE}/#{RUBY_PLATFORM}" " #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})" 9 | } 10 | 11 | def initialize(*args) 12 | options = args.last.is_a?(Hash) ? args.pop : {} 13 | args.select! {|arg| !arg.nil?} 14 | @config = BulutfonSDK::Util::ClientConfig.new options 15 | if args.count > 1 16 | @email = args[0] || nil 17 | @password = args[1] || nil 18 | @auth_type = 'credentials' 19 | else 20 | @token = args[0] || nil 21 | @auth_type = 'token' 22 | end 23 | raise ArgumentError, 'Auth token or user credentials are required' if (@token.nil? && (@email.nil? || @password.nil?)) 24 | set_up_connection 25 | end 26 | 27 | protected 28 | ## 29 | # Prepare URI object for file path 30 | def prepare_uri(path, params = {}) 31 | uri = uri_parse(params, path) 32 | uri.query = URI.encode_www_form(params) 33 | uri 34 | end 35 | 36 | ## 37 | # Prepare http request 38 | def prepare_request(method, path, params = {}) 39 | uri = uri_parse(params, path) 40 | uri.query = URI.encode_www_form(params) if ['get', 'delete'].include?(method) 41 | method_class = Net::HTTP.const_get method.to_s.capitalize 42 | request = method_class.new(uri.to_s, HTTP_HEADERS) 43 | request.form_data = params if ['post', 'put'].include?(method) 44 | connect_and_send(request) 45 | end 46 | 47 | ## 48 | # URI parse for params 49 | def uri_parse(params, path) 50 | request_path = "#{@config.host}/#{path}" 51 | uri = URI.parse(request_path) 52 | encrypt_token = params.delete(:encrypt_token) 53 | id = params.delete(:id) 54 | if @auth_type == 'credentials' 55 | params[:email] = @email 56 | params[:password] = @password 57 | else 58 | if encrypt_token && id.present? 59 | params[:access_token] = Digest::SHA1.hexdigest(@token.to_s + id.to_s) 60 | else 61 | params[:access_token] = @token 62 | end 63 | end 64 | uri 65 | end 66 | 67 | ## 68 | # Prepare http request for file saving 69 | def save_file(method, path, save_path, params = {}) 70 | uri = prepare_uri(path, params) 71 | method_class = Net::HTTP.const_get method.to_s.capitalize 72 | request = method_class.new(uri.to_s, HTTP_HEADERS) 73 | response = connect_and_send(request, is_file: true ) 74 | begin 75 | file = File.open(save_path, 'w') 76 | file.write(response) 77 | rescue => error 78 | raise BulutfonSDK::REST::SDKError.new error 79 | ensure 80 | file.close unless file.nil? 81 | end 82 | { file: file, save_path: save_path } 83 | end 84 | 85 | ## 86 | # Set up and cache a Net::HTTP object to use when making requests. 87 | def set_up_connection # :doc: 88 | uri = URI.parse(@config.host) 89 | @http = Net::HTTP.new(uri.host, uri.port, p_user = @config.proxy_user, p_pass = @config.proxy_pass) 90 | @http.verify_mode = OpenSSL::SSL::VERIFY_NONE 91 | @http.use_ssl = @config.use_ssl 92 | if @config.ssl_verify_peer 93 | @http.verify_mode = OpenSSL::SSL::VERIFY_PEER 94 | @http.ca_file = @config.ssl_ca_file 95 | else 96 | @http.verify_mode = OpenSSL::SSL::VERIFY_NONE 97 | end 98 | @http.open_timeout = @config.timeout 99 | @http.read_timeout = @config.timeout 100 | end 101 | 102 | ## 103 | # Send an HTTP request using the cached @http object and 104 | # return the JSON response body parsed into a hash. Also save the raw 105 | # Net::HTTP::Request and Net::HTTP::Response objects as 106 | # @last_request and @last_response to allow for 107 | # inspection later. 108 | def connect_and_send(request, is_file = false ) # :doc: 109 | @last_request = request 110 | retries_left = @config.retry_limit 111 | begin 112 | response = @http.request request 113 | @last_response = response 114 | if response.kind_of? Net::HTTPServerError 115 | raise BulutfonSDK::REST::ServerError 116 | end 117 | rescue 118 | raise if request.class == Net::HTTP::Post 119 | if retries_left > 0 then retries_left -= 1; retry else raise end 120 | end 121 | if response.body and !response.body.empty? 122 | if is_file 123 | object = response.body 124 | else 125 | object = MultiJson.load response.body 126 | end 127 | elsif response.kind_of? Net::HTTPBadRequest 128 | object = { message: 'Bad request', code: 400 } 129 | end 130 | 131 | if response.kind_of? Net::HTTPClientError 132 | raise BulutfonSDK::REST::RequestError.new object['error'], object['code'] 133 | end 134 | object 135 | end 136 | 137 | end 138 | end 139 | end 140 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/bulutfon.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Bulutfon < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | end 10 | 11 | def details 12 | prepare_request( 'get', 'me') 13 | end 14 | 15 | def messages 16 | BulutfonSDK::REST::Message.new(@token || @email, @password) 17 | end 18 | 19 | def message_titles 20 | BulutfonSDK::REST::MessageTitle.new(@token || @email, @password) 21 | end 22 | 23 | def extensions 24 | BulutfonSDK::REST::Extension.new(@token || @email, @password) 25 | end 26 | 27 | def dids 28 | BulutfonSDK::REST::Did.new(@token || @email, @password) 29 | end 30 | 31 | def groups 32 | BulutfonSDK::REST::Group.new(@token || @email, @password) 33 | end 34 | 35 | def cdrs 36 | BulutfonSDK::REST::Cdr.new(@token || @email, @password) 37 | end 38 | 39 | def call_records 40 | BulutfonSDK::REST::CallRecord.new(@token || @email, @password) 41 | end 42 | 43 | def incoming_faxes 44 | BulutfonSDK::REST::IncomingFax.new(@token || @email, @password) 45 | end 46 | 47 | def outgoing_faxes 48 | BulutfonSDK::REST::OutgoingFax.new(@token || @email, @password) 49 | end 50 | 51 | def announcements 52 | BulutfonSDK::REST::Announcement.new(@token || @email, @password) 53 | end 54 | 55 | def automatic_calls 56 | BulutfonSDK::REST::AutomaticCall.new(@token || @email, @password) 57 | end 58 | 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/call_record.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class CallRecord < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'call-records' 10 | end 11 | 12 | def get( uuid, encrypt_token = false ) 13 | uri = prepare_uri("#{@resource}/#{uuid}", {encrypt_token: encrypt_token, id: uuid}) 14 | { download_path: uri.to_s } 15 | end 16 | 17 | def get_stream( uuid, encrypt_token = false ) 18 | uri = prepare_uri("#{@resource}/#{uuid}/stream", {encrypt_token: encrypt_token, id: uuid}) 19 | { download_path: uri.to_s } 20 | end 21 | 22 | def save( uuid, save_path, encrypt_token = false) 23 | save_file( 'get', "#{@resource}/#{uuid}", save_path, {encrypt_token: encrypt_token, id: uuid}) 24 | end 25 | 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/cdr.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Cdr < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'cdrs' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | def get( uuid ) 17 | prepare_request( 'get', "#{@resource}/#{uuid}") 18 | end 19 | 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/did.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Did < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'dids' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | def get( id ) 17 | prepare_request( 'get', "#{@resource}/#{id}") 18 | end 19 | 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/errors.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | module REST 3 | class ServerError < StandardError; end 4 | 5 | class RequestError < StandardError 6 | attr_reader :code 7 | 8 | def initialize(message, code=nil) 9 | super message 10 | @code = code 11 | end 12 | end 13 | 14 | class SDKError < StandardError 15 | attr_reader :code 16 | 17 | def initialize(message, code=nil) 18 | super message 19 | @code = code 20 | end 21 | end 22 | 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/extension.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Extension < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'extensions' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | def get( id ) 17 | prepare_request( 'get', "#{@resource}/#{id}") 18 | end 19 | 20 | def create(params) 21 | prepare_request( 'post', @resource, params) 22 | end 23 | 24 | def update(id, params) 25 | prepare_request( 'put', "#{@resource}/#{id}", params) 26 | end 27 | 28 | def delete(id) 29 | prepare_request( 'delete', "#{@resource}/#{id}") 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/group.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Group < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'groups' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | def get( id ) 17 | prepare_request( 'get', "#{@resource}/#{id}") 18 | end 19 | 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/incoming_fax.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class IncomingFax < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'incoming-faxes' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource, params) 14 | end 15 | 16 | def get( uuid ) 17 | uri = prepare_uri("#{@resource}/#{uuid}") 18 | { download_path: uri.to_s } 19 | end 20 | 21 | def save( uuid, save_path) 22 | save_file( 'get', "#{@resource}/#{uuid}", save_path) 23 | end 24 | 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/message.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class Message < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'messages' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | def get( id ) 17 | prepare_request( 'get', "#{@resource}/#{id}") 18 | end 19 | 20 | def create(params) 21 | prepare_request( 'post', @resource, params) 22 | end 23 | 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/message_title.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class MessageTitle < BaseRequest 6 | 7 | def initialize(*args) 8 | super(*args) 9 | @resource = 'message-titles' 10 | end 11 | 12 | def all( params = {} ) 13 | prepare_request( 'get', @resource,params) 14 | end 15 | 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/rest/outgoing_fax.rb: -------------------------------------------------------------------------------- 1 | require 'bulutfon_sdk/rest/base_request' 2 | 3 | module BulutfonSDK 4 | module REST 5 | class OutgoingFax < BaseRequest 6 | 7 | include BulutfonSDK::Util 8 | 9 | def initialize(*args) 10 | super(*args) 11 | @resource = 'outgoing-faxes' 12 | end 13 | 14 | def all( params = {} ) 15 | prepare_request( 'get', @resource, params) 16 | end 17 | 18 | def get( id ) 19 | prepare_request( 'get', "#{@resource}/#{id}") 20 | end 21 | 22 | def create(params) 23 | prepare_atachment(params) 24 | prepare_request( 'post', @resource, params) 25 | end 26 | 27 | private 28 | 29 | def prepare_atachment(params) 30 | file = params[:attachment] 31 | basename = File.basename file 32 | type = file_content_type file 33 | content = File.read(file) 34 | base_64_data = Base64.strict_encode64(content) 35 | params[:attachment] = "data:#{type};name:#{basename};base64:#{base_64_data}" 36 | end 37 | 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/util.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | module Util 3 | def file_content_type(path) 4 | if File.exist? path 5 | stdin,stdout,stderr = Open3.popen3(%{file --mime -b #{path}}) 6 | 7 | file_err = stderr.gets 8 | file_out = stdout.gets 9 | 10 | raise BulutfonSDK::REST::SDKError.new "The 'file' command line binary was not found." if file_err 11 | 12 | return file_out.split(';')[0].strip if file_err.nil? && (!file_out.nil? && !file_out.empty?) 13 | end 14 | 15 | raise BulutfonSDK::REST::SDKError.new 'File content type not found' 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/util/client_config.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | module Util 3 | class ClientConfig 4 | DEFAULTS = { 5 | host: 'https://api.bulutfon.com', 6 | port: 80, 7 | use_ssl: true, 8 | ssl_verify_peer: false, 9 | ssl_ca_file: File.dirname(__FILE__) + '/../../../conf/cacert.pem', 10 | timeout: 30, 11 | proxy_addr: nil, 12 | proxy_port: nil, 13 | proxy_user: nil, 14 | proxy_pass: nil, 15 | retry_limit: 2 16 | } 17 | 18 | DEFAULTS.each_key do |attribute| 19 | attr_accessor attribute 20 | end 21 | 22 | def initialize(opts={}) 23 | DEFAULTS.each do |attribute, value| 24 | send("#{attribute}=".to_sym, opts.fetch(attribute, value)) 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/bulutfon_sdk/version.rb: -------------------------------------------------------------------------------- 1 | module BulutfonSDK 2 | VERSION = '1.3.0' 3 | end 4 | -------------------------------------------------------------------------------- /spec/bulutfon_sdk_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe BulutfonSDK do 4 | it 'has a version number' do 5 | expect(BulutfonSDK::VERSION).not_to be nil 6 | end 7 | 8 | it 'does something useful' do 9 | expect(false).to eq(true) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | require 'bulutfon_sdk' 3 | --------------------------------------------------------------------------------