omise 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26de59160d14b03572bf1697765e0055033bde51
4
- data.tar.gz: df763a37a7abeb4f5b8dcf547e6a2042370437ab
3
+ metadata.gz: e6b2f56981a89d8705862e3a3649803458ed8ba8
4
+ data.tar.gz: eeecbe3fced3152b59b4fc7956c89ea0800021df
5
5
  SHA512:
6
- metadata.gz: de7f8dab27de2aacf55c78f55d067c8eb31eec125b05db1a21c150b7229a459f347342a59c23c5b8ac89668a8a47770f24ddf4ed5da8ed071338b4448b347512
7
- data.tar.gz: 3f48a5677710a2126aa4af36d38891a2488cc10ba673558c1696f73b5be9a8830130a1d31057ebe3aa3bacfbce6d2004ee02d81b96369df27b1a1e43df30c724
6
+ metadata.gz: 1a9b3226f8a0db71ef9f6b47569aee173d6e0aecb437d142552cee6a16af9348e5b4664ccf26901e0a080f1d63c2900cbfe003c723e9e02262c7b08a22ec12e9
7
+ data.tar.gz: b4e0cffe3356323389e2421df5a97a38ab60542b25e75f31d47b11094ae137359c96b372e433d0cd8c89dcf70384a970f8a49aaf997c2dc1760514e015a9d19d
@@ -4,6 +4,10 @@ An [unreleased] version is not available on rubygems and is subject to changes a
4
4
 
5
5
  ## [unreleased]
6
6
 
7
+ - [Added] Schedule and Occurence
8
+
9
+ ## [0.5.1] 2017-04-16
10
+
7
11
  - [Added] Support to log HTTP requests and responses.
8
12
  - [Added] Rename keys with better names while supporting old methods
9
13
  - [Fix] Avoid circular require warnings when running tests
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: "2.3.3"
@@ -8,9 +8,11 @@ require "omise/dispute"
8
8
  require "omise/document"
9
9
  require "omise/event"
10
10
  require "omise/link"
11
+ require "omise/occurrence"
11
12
  require "omise/recipient"
12
13
  require "omise/refund"
13
14
  require "omise/search"
15
+ require "omise/schedule"
14
16
  require "omise/token"
15
17
  require "omise/transaction"
16
18
  require "omise/transfer"
@@ -2,6 +2,7 @@ require "omise/object"
2
2
  require "omise/list"
3
3
  require "omise/refund_list"
4
4
  require "omise/search_scope"
5
+ require "omise/scheduler"
5
6
 
6
7
  module Omise
7
8
  class Charge < OmiseObject
@@ -11,6 +12,10 @@ module Omise
11
12
  SearchScope.new(:charge)
12
13
  end
13
14
 
15
+ def self.schedule(attributes = {})
16
+ Scheduler.new(:charge, attributes)
17
+ end
18
+
14
19
  def self.retrieve(id, attributes = {})
15
20
  new resource(location(id), attributes).get(attributes)
16
21
  end
@@ -4,7 +4,7 @@ require "omise/charge"
4
4
  module Omise
5
5
  class ChargeList < List
6
6
  def retrieve(id, attributes = {})
7
- Charge.retrieve(id)
7
+ Charge.retrieve(id, attributes)
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,23 @@
1
+ require "omise/object"
2
+
3
+ module Omise
4
+ class Occurrence < OmiseObject
5
+ self.endpoint = "/occurrences"
6
+
7
+ def self.retrieve(id, attributes = {})
8
+ new resource(location(id), attributes).get(attributes)
9
+ end
10
+
11
+ def schedule(options = {})
12
+ if !defined?(Schedule)
13
+ require "omise/schedule"
14
+ end
15
+
16
+ expand_attribute Schedule, "schedule", options
17
+ end
18
+
19
+ def reload(attributes = {})
20
+ assign_attributes resource(attributes).get(attributes)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ require "omise/list"
2
+ require "omise/occurrence"
3
+
4
+ module Omise
5
+ class OccurrenceList < List
6
+ def retrieve(id, attributes = {})
7
+ Occurrence.retrieve(id, attributes)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ require "omise/object"
2
+ require "omise/list"
3
+ require "omise/occurrence_list"
4
+
5
+ module Omise
6
+ class Schedule < OmiseObject
7
+ self.endpoint = "/schedules"
8
+
9
+ def self.list(attributes = {})
10
+ List.new resource(location, attributes).get(attributes)
11
+ end
12
+
13
+ def self.retrieve(id, attributes = {})
14
+ new resource(location(id), attributes).get(attributes)
15
+ end
16
+
17
+ def self.create(attributes = {})
18
+ new resource(location, attributes).post(attributes)
19
+ end
20
+
21
+ def occurrences
22
+ list_attribute OccurrenceList, "occurrences"
23
+ end
24
+
25
+ def destroy(attributes = {})
26
+ assign_attributes resource(attributes).delete
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,149 @@
1
+ require "date"
2
+
3
+ require "omise/schedule"
4
+
5
+ module Omise
6
+ class Scheduler
7
+ WEEKDAYS = Date::DAYNAMES.map(&:downcase).freeze
8
+ MONTH_WEEKDAYS = %w[first second third fourth last]
9
+ .product(WEEKDAYS)
10
+ .map { |d| d.join("_") }
11
+ .freeze
12
+
13
+ def initialize(type, attributes = {}, options = {})
14
+ @type = type
15
+ @attributes = attributes
16
+ @every = options[:every]
17
+ @period = options[:period]
18
+ @on = options[:on]
19
+ @end_date = options[:end_date]
20
+ end
21
+
22
+ def type
23
+ @type.to_s
24
+ end
25
+
26
+ def every(n = 1)
27
+ unless n.is_a?(Integer)
28
+ raise TypeError, "#{n} is not an Integer"
29
+ end
30
+
31
+ renew(every: n)
32
+ end
33
+
34
+ def days
35
+ renew(period: "day", on: nil)
36
+ end
37
+ alias_method :day, :days
38
+
39
+ def weeks(on:)
40
+ on.each do |day|
41
+ unless WEEKDAYS.include?(day)
42
+ raise "#{day} is not one of #{WEEKDAYS}"
43
+ end
44
+ end
45
+
46
+ renew(period: "week", on: { weekdays: on })
47
+ end
48
+ alias_method :week, :weeks
49
+
50
+ def months(on:)
51
+ case on
52
+ when Array
53
+ month_with_days(on)
54
+ when String
55
+ month_with_weekday(on)
56
+ else
57
+ raise TypeError, "#{on.inspect} must be an Array or a String, not a #{on.class}"
58
+ end
59
+ end
60
+ alias_method :month, :months
61
+
62
+ def end_date(date)
63
+ date = Date.parse(date.to_s)
64
+ renew(end_date: date.iso8601)
65
+ end
66
+
67
+ def parse(str)
68
+ str = str.downcase
69
+ .gsub(/ +/, " ")
70
+ .gsub("every ", "")
71
+ .gsub("the ", "")
72
+ .gsub(" and ", ",")
73
+ .gsub(/,+/, ",")
74
+ .gsub(/ ?, ?/, ",")
75
+ .gsub(",", " ")
76
+
77
+ leftover, end_date = str.split(" until ", 2)
78
+ period, on = leftover.split(" on ", 2)
79
+ on = on.to_s.strip.split(" ")
80
+ every = period.to_i
81
+ every = 1 if every.zero?
82
+ month_weekday = on.join("_")
83
+ month_days = on.map { |d| d.to_i }
84
+
85
+ schedule = self.end_date(end_date).every(every)
86
+
87
+ if period.include?("day")
88
+ return schedule.days
89
+ end
90
+
91
+ if period.include?("week")
92
+ return schedule.weeks(on: on.uniq)
93
+ end
94
+
95
+ if period.include?("month") && MONTH_WEEKDAYS.include?(month_weekday)
96
+ return schedule.months(on: month_weekday)
97
+ end
98
+
99
+ if period.include?("month")
100
+ return schedule.months(on: month_days.uniq)
101
+ end
102
+
103
+ raise ArgumentError, "invalid schedule: #{src}"
104
+ end
105
+
106
+ def start
107
+ Schedule.create(to_attributes)
108
+ end
109
+
110
+ def to_attributes
111
+ {}.tap do |a|
112
+ a[@type] = @attributes
113
+ a[:every] = @every if @every
114
+ a[:period] = @period if @period
115
+ a[:on] = @on if @on
116
+ a[:end_date] = @end_date if @end_date
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def month_with_days(days)
123
+ days.each do |day|
124
+ unless day.is_a?(Integer)
125
+ raise TypeError, "#{day.inspect} must be an Integer, not a #{day.class}"
126
+ end
127
+ end
128
+
129
+ renew(period: "month", on: { days_of_month: days })
130
+ end
131
+
132
+ def month_with_weekday(day)
133
+ unless MONTH_WEEKDAYS.include?(day)
134
+ raise "#{day} does not match #{WEEKDAY_OF_MONTH.inspect}"
135
+ end
136
+
137
+ renew(period: "month", on: { weekday_of_month: day })
138
+ end
139
+
140
+ def renew(attributes)
141
+ self.class.new(@type, @attributes, {
142
+ every: @every,
143
+ period: @period,
144
+ on: @on,
145
+ end_date: @end_date,
146
+ }.merge(attributes))
147
+ end
148
+ end
149
+ end
@@ -34,15 +34,13 @@ module Omise
34
34
  end
35
35
 
36
36
  def to_attributes
37
- attributes = {}
38
-
39
- attributes[:scope] = @scope
40
- attributes[:filters] = @filters if @filters.any?
41
- attributes[:query] = @query if @query
42
- attributes[:order] = @order if @order
43
- attributes[:page] = @page if @page
44
-
45
- attributes
37
+ {}.tap do |a|
38
+ a[:scope] = @scope
39
+ a[:filters] = @filters if @filters.any?
40
+ a[:query] = @query if @query
41
+ a[:order] = @order if @order
42
+ a[:page] = @page if @page
43
+ end
46
44
  end
47
45
 
48
46
  private
@@ -10,6 +10,10 @@ module Omise
10
10
  SearchScope.new(:transfer)
11
11
  end
12
12
 
13
+ def self.schedule(attributes = {})
14
+ Scheduler.new(:transfer, attributes)
15
+ end
16
+
13
17
  def self.create(attributes = {})
14
18
  new resource(location, attributes).post(attributes)
15
19
  end
@@ -1,3 +1,3 @@
1
1
  module Omise
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -0,0 +1,6 @@
1
+ {
2
+ "object": "occurrence",
3
+ "location": "/occurrences/occu_test_57s33hmja9t3fs4wmop",
4
+ "id": "occu_test_57s33hmja9t3fs4wmop",
5
+ "schedule": "schd_test_4yq7duw15p9hdrjp8oq"
6
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "object": "list",
3
+ "data": [
4
+ {
5
+ "object": "schedule",
6
+ "location": "/schedules/schd_test_4yq7duw15p9hdrjp8oq",
7
+ "id": "schd_test_4yq7duw15p9hdrjp8oq"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "object": "schedule",
3
+ "location": "/schedules/schd_test_4yq7duw15p9hdrjp8oq",
4
+ "id": "schd_test_4yq7duw15p9hdrjp8oq"
5
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "object": "schedule",
3
+ "location": "/schedules/schd_test_4yq7duw15p9hdrjp8oq",
4
+ "id": "schd_test_4yq7duw15p9hdrjp8oq",
5
+ "deleted": true
6
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "object": "schedule",
3
+ "location": "/schedules/schd_test_4yq7duw15p9hdrjp8oq",
4
+ "id": "schd_test_4yq7duw15p9hdrjp8oq",
5
+ "occurrences": {
6
+ "object": "list",
7
+ "from": "1970-01-01T00:00:00+00:00",
8
+ "to": "2015-01-15T05:04:30+00:00",
9
+ "offset": 0,
10
+ "limit": 20,
11
+ "total": 1,
12
+ "data": [
13
+ {
14
+ "object": "occurrence",
15
+ "location": "/occurrences/occu_test_57s33hmja9t3fs4wmop",
16
+ "id": "occu_test_57s33hmja9t3fs4wmop"
17
+ }
18
+ ]
19
+ }
20
+ }
@@ -115,4 +115,9 @@ class TestCharge < Omise::Test
115
115
  assert_instance_of Omise::SearchScope, Omise::Charge.search
116
116
  assert_equal "charge", Omise::Charge.search.scope
117
117
  end
118
+
119
+ def test_that_schedule_returns_a_scheduler
120
+ assert_instance_of Omise::Scheduler, Omise::Charge.schedule
121
+ assert_equal "charge", Omise::Charge.schedule.type
122
+ end
118
123
  end
@@ -0,0 +1,29 @@
1
+ require "support"
2
+
3
+ class TestOccurrence < Omise::Test
4
+ setup do
5
+ @schedule = Omise::Schedule.retrieve("schd_test_4yq7duw15p9hdrjp8oq")
6
+ @occurrence = Omise::Occurrence.retrieve("occu_test_57s33hmja9t3fs4wmop")
7
+ end
8
+
9
+ def test_that_we_can_retrieve_an_occurrence
10
+ occurrence = Omise::Occurrence.retrieve("occu_test_57s33hmja9t3fs4wmop")
11
+
12
+ assert_instance_of Omise::Occurrence, occurrence
13
+ end
14
+
15
+ def test_that_we_can_reload_an_occurrence
16
+ occurrence = Omise::Occurrence.retrieve("occu_test_57s33hmja9t3fs4wmop")
17
+
18
+ occurrence.reload
19
+
20
+ assert_instance_of Omise::Occurrence, occurrence
21
+ end
22
+
23
+ def test_that_we_can_expand_a_schedule
24
+ occurrence = Omise::Occurrence.retrieve("occu_test_57s33hmja9t3fs4wmop")
25
+ schedule = occurrence.schedule
26
+
27
+ assert_instance_of Omise::Schedule, schedule
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ require "support"
2
+
3
+ class TestSchedule < Omise::Test
4
+ setup do
5
+ @schedule = Omise::Schedule.retrieve("schd_test_4yq7duw15p9hdrjp8oq")
6
+ end
7
+
8
+ def test_that_we_can_list_all_schedules
9
+ schedules = Omise::Schedule.list
10
+
11
+ assert_instance_of Omise::List, schedules
12
+ assert_instance_of Omise::Schedule, schedules.first
13
+ end
14
+
15
+ def test_that_we_can_retrieve_a_schedule
16
+ assert_instance_of Omise::Schedule, @schedule
17
+ end
18
+
19
+ def test_that_we_can_create_a_schedule
20
+ schedule = Omise::Schedule.create({
21
+ every: 1,
22
+ period: "month",
23
+ start_date: "2017-05-01",
24
+ end_date: "2018-05-01",
25
+ on: {
26
+ days_of_month: [1],
27
+ },
28
+ charge: {
29
+ customer: "cust_test_57m2wcnfx96k634rkqq",
30
+ amount: "100000",
31
+ },
32
+ })
33
+
34
+ assert_instance_of Omise::Schedule, schedule
35
+ end
36
+
37
+ def test_that_we_can_destroy_a_schedule
38
+ @schedule.destroy
39
+
40
+ assert @schedule.destroyed?
41
+ end
42
+
43
+ def test_that_we_can_list_occurences
44
+ occurrences = @schedule.occurrences
45
+
46
+ assert_instance_of Omise::OccurrenceList, occurrences
47
+ assert_instance_of Omise::Occurrence, occurrences.first
48
+ end
49
+ end
@@ -0,0 +1,179 @@
1
+ require "support"
2
+
3
+ class TestScheduler < Omise::Test
4
+ setup do
5
+ @scheduler = Omise::Charge.schedule
6
+ end
7
+
8
+ def test_that_a_scheduler_has_a_type
9
+ assert_equal "charge", @scheduler.type
10
+ end
11
+
12
+ def test_we_can_set_every
13
+ scheduler = @scheduler.every(1)
14
+
15
+ assert_scheduler_attributes(@scheduler)
16
+ refute_equal scheduler.object_id, @scheduler.object_id
17
+ assert_equal 1, scheduler.to_attributes[:every]
18
+ end
19
+
20
+ def test_we_can_set_day
21
+ scheduler = @scheduler.every(1).day
22
+
23
+ assert_scheduler_attributes(@scheduler)
24
+ refute_equal scheduler.object_id, @scheduler.object_id
25
+ assert_equal 1, scheduler.to_attributes[:every]
26
+ assert_equal "day", scheduler.to_attributes[:period]
27
+ assert_nil scheduler.to_attributes[:on]
28
+ end
29
+
30
+ def test_we_can_set_days
31
+ scheduler = @scheduler.every(10).days
32
+
33
+ assert_scheduler_attributes(@scheduler)
34
+ refute_equal scheduler.object_id, @scheduler.object_id
35
+ assert_equal 10, scheduler.to_attributes[:every]
36
+ assert_equal "day", scheduler.to_attributes[:period]
37
+ assert_nil scheduler.to_attributes[:on]
38
+ end
39
+
40
+ def test_we_can_set_week
41
+ scheduler = @scheduler.every(1).week(on: ["monday"])
42
+
43
+ assert_scheduler_attributes(@scheduler)
44
+ refute_equal scheduler.object_id, @scheduler.object_id
45
+ assert_equal 1, scheduler.to_attributes[:every]
46
+ assert_equal "week", scheduler.to_attributes[:period]
47
+ assert_equal ["monday"], scheduler.to_attributes[:on][:weekdays]
48
+ end
49
+
50
+ def test_we_can_set_weeks
51
+ scheduler = @scheduler.every(2).weeks(on: ["monday"])
52
+
53
+ assert_scheduler_attributes(@scheduler)
54
+ refute_equal scheduler.object_id, @scheduler.object_id
55
+ assert_equal 2, scheduler.to_attributes[:every]
56
+ assert_equal "week", scheduler.to_attributes[:period]
57
+ assert_equal ["monday"], scheduler.to_attributes[:on][:weekdays]
58
+ end
59
+
60
+ def test_we_can_set_month_with_days
61
+ scheduler = @scheduler.every(1).month(on: [1, 10, 20])
62
+
63
+ assert_scheduler_attributes(@scheduler)
64
+ refute_equal scheduler.object_id, @scheduler.object_id
65
+ assert_equal 1, scheduler.to_attributes[:every]
66
+ assert_equal "month", scheduler.to_attributes[:period]
67
+ assert_equal [1, 10, 20], scheduler.to_attributes[:on][:days_of_month]
68
+ end
69
+
70
+ def test_we_can_set_months_with_days
71
+ scheduler = @scheduler.every(3).months(on: [1])
72
+
73
+ assert_scheduler_attributes(@scheduler)
74
+ refute_equal scheduler.object_id, @scheduler.object_id
75
+ assert_equal 3, scheduler.to_attributes[:every]
76
+ assert_equal "month", scheduler.to_attributes[:period]
77
+ assert_equal [1], scheduler.to_attributes[:on][:days_of_month]
78
+ end
79
+
80
+ def test_we_can_set_month_with_weekday
81
+ scheduler = @scheduler.every(1).month(on: "first_monday")
82
+
83
+ assert_scheduler_attributes(@scheduler)
84
+ refute_equal scheduler.object_id, @scheduler.object_id
85
+ assert_equal 1, scheduler.to_attributes[:every]
86
+ assert_equal "month", scheduler.to_attributes[:period]
87
+ assert_equal "first_monday", scheduler.to_attributes[:on][:weekday_of_month]
88
+ end
89
+
90
+ def test_we_can_set_months_with_weekday
91
+ scheduler = @scheduler.every(3).months(on: "last_friday")
92
+
93
+ assert_scheduler_attributes(@scheduler)
94
+ refute_equal scheduler.object_id, @scheduler.object_id
95
+ assert_equal 3, scheduler.to_attributes[:every]
96
+ assert_equal "month", scheduler.to_attributes[:period]
97
+ assert_equal "last_friday", scheduler.to_attributes[:on][:weekday_of_month]
98
+ end
99
+
100
+ def test_we_can_set_end_date
101
+ scheduler = @scheduler.end_date("2018-01-01")
102
+
103
+ assert_scheduler_attributes(@scheduler)
104
+ refute_equal scheduler.object_id, @scheduler.object_id
105
+ assert_equal "2018-01-01", scheduler.to_attributes[:end_date]
106
+ end
107
+
108
+ def test_we_can_set_end_date_in_other_formats
109
+ scheduler = @scheduler.end_date("1st January 2018")
110
+
111
+ assert_scheduler_attributes(@scheduler)
112
+ refute_equal scheduler.object_id, @scheduler.object_id
113
+ assert_equal "2018-01-01", scheduler.to_attributes[:end_date]
114
+ end
115
+
116
+ def that_we_can_parse_it_all_in_one
117
+ scheduler = @scheduler.parse("every 1 month on the 28th until May 1st, 2018")
118
+
119
+ assert_scheduler_attributes(@scheduler)
120
+ assert_scheduler_attributes(scheduler, 1, "month", "2018-05-01", days_of_month: [28])
121
+ end
122
+
123
+ def test_a_bunch_of_other_values_to_be_parsed
124
+ scheduler = @scheduler.parse("every day until 03/04/2018")
125
+ assert_scheduler_attributes(scheduler, 1, "day", "2018-04-03")
126
+
127
+ scheduler = @scheduler.parse("every 10 days until 03/04/2018")
128
+ assert_scheduler_attributes(scheduler, 10, "day", "2018-04-03")
129
+
130
+ scheduler = @scheduler.parse("every 2 weeks on monday and friday until 2018-12-12")
131
+ assert_scheduler_attributes(scheduler, 2, "week", "2018-12-12", weekdays: ["monday", "friday"])
132
+
133
+ scheduler = @scheduler.parse("every 1 week on monday, tuesday, wednesday, thursday, friday until 2018-12-12")
134
+ assert_scheduler_attributes(scheduler, 1, "week", "2018-12-12", weekdays: ["monday", "tuesday", "wednesday", "thursday", "friday"])
135
+
136
+ scheduler = @scheduler.parse("every 2 weeks on monday and monday until 2018-12-12")
137
+ assert_scheduler_attributes(scheduler, 2, "week", "2018-12-12", weekdays: ["monday"])
138
+
139
+ scheduler = @scheduler.parse("every month on the third Thursday until January 1st 2020")
140
+ assert_scheduler_attributes(scheduler, 1, "month", "2020-01-01", weekday_of_month: "third_thursday")
141
+
142
+ scheduler = @scheduler.parse("every 3 months on 1, 2 and 3 until January 1st 2020")
143
+ assert_scheduler_attributes(scheduler, 3, "month", "2020-01-01", days_of_month: [1, 2, 3])
144
+ end
145
+
146
+ def test_that_we_can_start_the_schedule
147
+ schedule = @scheduler.parse("every 1 month on the 28th until May 1st, 2018").start
148
+
149
+ assert_instance_of Omise::Schedule, schedule
150
+ end
151
+
152
+ private
153
+
154
+ def assert_scheduler_attributes(scheduler, every = nil, period = nil, end_date = nil, on = nil)
155
+ if every
156
+ assert_equal every, scheduler.to_attributes[:every]
157
+ else
158
+ assert_nil every
159
+ end
160
+
161
+ if period
162
+ assert_equal period, scheduler.to_attributes[:period]
163
+ else
164
+ assert_nil period
165
+ end
166
+
167
+ if end_date
168
+ assert_equal end_date, scheduler.to_attributes[:end_date]
169
+ else
170
+ assert_nil end_date
171
+ end
172
+
173
+ if on
174
+ assert_equal on, scheduler.to_attributes[:on]
175
+ else
176
+ assert_nil on
177
+ end
178
+ end
179
+ end
@@ -42,4 +42,14 @@ class TestTransfer < Omise::Test
42
42
  def test_that_a_transfer_has_a_bank_account
43
43
  assert_instance_of Omise::BankAccount, @transfer.bank_account
44
44
  end
45
+
46
+ def test_that_search_returns_a_scoped_search
47
+ assert_instance_of Omise::SearchScope, Omise::Transfer.search
48
+ assert_equal "transfer", Omise::Transfer.search.scope
49
+ end
50
+
51
+ def test_that_schedule_returns_a_scheduler
52
+ assert_instance_of Omise::Scheduler, Omise::Transfer.schedule
53
+ assert_equal "transfer", Omise::Transfer.schedule.type
54
+ end
45
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Clart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-16 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -109,6 +109,7 @@ files:
109
109
  - Rakefile
110
110
  - bin/console
111
111
  - bin/rake
112
+ - circle.yml
112
113
  - data/ca_certificates.pem
113
114
  - lib/omise.rb
114
115
  - lib/omise/account.rb
@@ -131,10 +132,14 @@ files:
131
132
  - lib/omise/link.rb
132
133
  - lib/omise/list.rb
133
134
  - lib/omise/object.rb
135
+ - lib/omise/occurrence.rb
136
+ - lib/omise/occurrence_list.rb
134
137
  - lib/omise/recipient.rb
135
138
  - lib/omise/refund.rb
136
139
  - lib/omise/refund_list.rb
137
140
  - lib/omise/resource.rb
141
+ - lib/omise/schedule.rb
142
+ - lib/omise/scheduler.rb
138
143
  - lib/omise/search.rb
139
144
  - lib/omise/search_scope.rb
140
145
  - lib/omise/singleton_resource.rb
@@ -188,11 +193,16 @@ files:
188
193
  - test/fixtures/api.omise.co/links-get.json
189
194
  - test/fixtures/api.omise.co/links-post.json
190
195
  - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
196
+ - test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
191
197
  - test/fixtures/api.omise.co/recipients-get.json
192
198
  - test/fixtures/api.omise.co/recipients-post.json
193
199
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
194
200
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-get.json
195
201
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-patch.json
202
+ - test/fixtures/api.omise.co/schedules-get.json
203
+ - test/fixtures/api.omise.co/schedules-post.json
204
+ - test/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-delete.json
205
+ - test/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-get.json
196
206
  - test/fixtures/api.omise.co/search-get-scope-charge.json
197
207
  - test/fixtures/api.omise.co/transactions-get.json
198
208
  - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
@@ -218,9 +228,12 @@ files:
218
228
  - test/omise/test_http_logger.rb
219
229
  - test/omise/test_link.rb
220
230
  - test/omise/test_list.rb
231
+ - test/omise/test_occurrence.rb
221
232
  - test/omise/test_recipient.rb
222
233
  - test/omise/test_refund.rb
223
234
  - test/omise/test_resource.rb
235
+ - test/omise/test_schedule.rb
236
+ - test/omise/test_scheduler.rb
224
237
  - test/omise/test_search.rb
225
238
  - test/omise/test_search_scope.rb
226
239
  - test/omise/test_token.rb
@@ -248,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
261
  version: '0'
249
262
  requirements: []
250
263
  rubyforge_project:
251
- rubygems_version: 2.6.8
264
+ rubygems_version: 2.6.11
252
265
  signing_key:
253
266
  specification_version: 4
254
267
  summary: Omise Ruby client
@@ -295,11 +308,16 @@ test_files:
295
308
  - test/fixtures/api.omise.co/links-get.json
296
309
  - test/fixtures/api.omise.co/links-post.json
297
310
  - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
311
+ - test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
298
312
  - test/fixtures/api.omise.co/recipients-get.json
299
313
  - test/fixtures/api.omise.co/recipients-post.json
300
314
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
301
315
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-get.json
302
316
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-patch.json
317
+ - test/fixtures/api.omise.co/schedules-get.json
318
+ - test/fixtures/api.omise.co/schedules-post.json
319
+ - test/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-delete.json
320
+ - test/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-get.json
303
321
  - test/fixtures/api.omise.co/search-get-scope-charge.json
304
322
  - test/fixtures/api.omise.co/transactions-get.json
305
323
  - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
@@ -325,9 +343,12 @@ test_files:
325
343
  - test/omise/test_http_logger.rb
326
344
  - test/omise/test_link.rb
327
345
  - test/omise/test_list.rb
346
+ - test/omise/test_occurrence.rb
328
347
  - test/omise/test_recipient.rb
329
348
  - test/omise/test_refund.rb
330
349
  - test/omise/test_resource.rb
350
+ - test/omise/test_schedule.rb
351
+ - test/omise/test_scheduler.rb
331
352
  - test/omise/test_search.rb
332
353
  - test/omise/test_search_scope.rb
333
354
  - test/omise/test_token.rb