Class: IletimerkeziSdk::Services::BlacklistService
- Inherits:
-
Object
- Object
- IletimerkeziSdk::Services::BlacklistService
- Defined in:
- lib/iletimerkezi_sdk/services/blacklist_service.rb
Instance Method Summary collapse
- #add(numbers) ⇒ Object
- #delete(numbers) ⇒ Object
-
#initialize(http_client, api_key, api_hash) ⇒ BlacklistService
constructor
A new instance of BlacklistService.
- #list(start_date = nil, end_date = nil, page = 1) ⇒ Object
- #next ⇒ Object
Constructor Details
#initialize(http_client, api_key, api_hash) ⇒ BlacklistService
Returns a new instance of BlacklistService.
4 5 6 7 8 9 10 11 |
# File 'lib/iletimerkezi_sdk/services/blacklist_service.rb', line 4 def initialize(http_client, api_key, api_hash) @http_client = http_client @api_key = api_key @api_hash = api_hash @last_start_date = nil @last_end_date = nil @last_page = nil end |
Instance Method Details
#add(numbers) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/iletimerkezi_sdk/services/blacklist_service.rb', line 49 def add(numbers) payload = { request: { authentication: { key: @api_key, hash: @api_hash }, blacklist: { number: Array(numbers).first } } } response = @http_client.post('add-blacklist/json', json: payload) Responses::BaseResponse.new(response[:body], response[:status]) end |
#delete(numbers) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/iletimerkezi_sdk/services/blacklist_service.rb', line 66 def delete(numbers) payload = { request: { authentication: { key: @api_key, hash: @api_hash }, blacklist: { number: Array(numbers).first } } } response = @http_client.post('delete-blacklist/json', json: payload) Responses::BaseResponse.new(response[:body], response[:status]) end |
#list(start_date = nil, end_date = nil, page = 1) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/iletimerkezi_sdk/services/blacklist_service.rb', line 13 def list(start_date = nil, end_date = nil, page = 1) @last_start_date = start_date @last_end_date = end_date @last_page = page payload = { request: { authentication: { key: @api_key, hash: @api_hash }, blacklist: { page: page, rowCount: 1000 } } } if start_date && end_date payload[:request][:blacklist][:filter] = { start: start_date, end: end_date } end response = @http_client.post('get-blacklist/json', json: payload) Responses::BlacklistResponse.new(response[:body], response[:status]) end |
#next ⇒ Object
43 44 45 46 47 |
# File 'lib/iletimerkezi_sdk/services/blacklist_service.rb', line 43 def next return nil unless @last_page list(@last_start_date, @last_end_date, @last_page + 1) end |