rajaongkir 0.1.2 → 0.1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rajaongkir.rb +10 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3913666ea8fc38b8382896ef17c6d50f11793b6a
4
- data.tar.gz: dd33cddea57c84c1d56d20021df284c353232f73
3
+ metadata.gz: 82d2b0f839c48a3e211e954b6bd6be0fccd624d7
4
+ data.tar.gz: cbd5250d079a3a91aad95a99a47f950abaf40247
5
5
  SHA512:
6
- metadata.gz: 0168a4bcc3e63fde9165c1daf5f29591a28ed6719cf5d000c6213f03c715707723596b3c0bb0ea1693ed2a35cfdd70f38690567327a595d6bfc0a6c88617fc17
7
- data.tar.gz: c16f558c50d30104431421b9aea24d97f1e5ead0e0312e5625d5defd9d331361d96e00ffd730d557a6f0366c917902ec33cf503d8dc7f5fcf083f25914f3b0ee
6
+ metadata.gz: f5283ca7c718a17ec9f3bea07a4d28bb5ca8e056a1c62e671f1c9486c1742795084d5aef5aa6bb18d8bfcb9df1998f60687ade91399e0e3521ef7a52406df1d6
7
+ data.tar.gz: c9ecd3315bc71b3fbac60859bb7179f54db91c6df2bfbcd2999b0873bc660fdcdd2f121a685cd456072dd054886210e608eb270f910d2f9bd26edf28e6575c10
@@ -5,25 +5,26 @@ require 'unirest'
5
5
  # http://rajaongkir.com/dokumentasi
6
6
 
7
7
  class Rajaongkir
8
+ attr_accessor :key, :base_url
8
9
 
9
10
  # key = API KEY dari rajaongkir
10
11
  def initialize(key = nil)
11
- $key = key
12
- $base_url = "http://rajaongkir.com/api/"
12
+ @key = key
13
+ @base_url = "http://rajaongkir.com/api/"
13
14
  end
14
15
 
15
16
  # fungsi untuk mendapatkan data kota
16
17
  #
17
18
  # params = {'province' => '6', 'id' => '161'}
18
19
  def city(params = nil)
19
- execute "city",params
20
+ request "city",params
20
21
  end
21
22
 
22
23
  # fungsi untuk mendapatkan data provinsi
23
24
  #
24
25
  # params = {'id' => '6'}
25
26
  def province(params = nil)
26
- execute "province", params
27
+ request "province", params
27
28
  end
28
29
 
29
30
  # fungsi untuk mendapatkan data ongkos kirim
@@ -35,19 +36,19 @@ class Rajaongkir
35
36
  def cost(origin, destination, weight, courier = 'pos')
36
37
  params = {:origin => origin, :destination => destination, :weight => weight, :courier => courier}
37
38
 
38
- execute "cost", params, 'post'
39
+ request "cost", params, 'post'
39
40
  end
40
41
 
41
42
  # fungsi untuk mengirimkan request ke rajaongkir
42
43
  private
43
- def execute(function, params = nil, http_method = 'get')
44
- if $key.nil? || $key == ''
44
+ def request(function, params = nil, http_method = 'get')
45
+ if @key.nil? || @key == ''
45
46
  return "API-KEY tidak boleh kosong"
46
47
  else
47
48
  return Unirest.send(
48
49
  http_method.to_sym,
49
- $base_url + function,
50
- headers:{"key" => $key},
50
+ @base_url + function,
51
+ headers:{"key" => @key},
51
52
  parameters: params
52
53
  )
53
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rajaongkir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Yunanto
@@ -31,7 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/rajaongkir.rb
34
- homepage: http://rubygems.org/gems/rajaongkir
34
+ homepage: https://github.com/iorme/rajaongkir-rb
35
35
  licenses:
36
36
  - MIT
37
37
  metadata: {}