turba_kit 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +15 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +1 -0
  6. data/Rakefile +22 -0
  7. data/lib/turba_kit/arguments.rb +14 -0
  8. data/lib/turba_kit/authentication.rb +10 -0
  9. data/lib/turba_kit/client/categories.rb +41 -0
  10. data/lib/turba_kit/client/checkins.rb +14 -0
  11. data/lib/turba_kit/client/comments.rb +9 -0
  12. data/lib/turba_kit/client/contents.rb +26 -0
  13. data/lib/turba_kit/client/countries.rb +14 -0
  14. data/lib/turba_kit/client/crowd_table.rb +25 -0
  15. data/lib/turba_kit/client/links.rb +26 -0
  16. data/lib/turba_kit/client/migrations.rb +15 -0
  17. data/lib/turba_kit/client/notifications.rb +26 -0
  18. data/lib/turba_kit/client/organismes.rb +41 -0
  19. data/lib/turba_kit/client/phonenumbers.rb +26 -0
  20. data/lib/turba_kit/client/places.rb +26 -0
  21. data/lib/turba_kit/client/search.rb +9 -0
  22. data/lib/turba_kit/client/services.rb +41 -0
  23. data/lib/turba_kit/client/tips.rb +26 -0
  24. data/lib/turba_kit/client.rb +168 -0
  25. data/lib/turba_kit/configurable.rb +74 -0
  26. data/lib/turba_kit/default.rb +102 -0
  27. data/lib/turba_kit/error.rb +209 -0
  28. data/lib/turba_kit/response/raise_error.rb +20 -0
  29. data/lib/turba_kit/version.rb +3 -0
  30. data/lib/turba_kit.rb +27 -0
  31. data/spec/cassettes/TurbaKit_Client_Categories/_categories/handles_the_country_code_option.json +1 -0
  32. data/spec/cassettes/TurbaKit_Client_Categories/_category/returns_a_category.json +1 -0
  33. data/spec/cassettes/TurbaKit_Client_Categories/_create_category/creates_a_category.json +1 -0
  34. data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +1 -0
  35. data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +1 -0
  36. data/spec/cassettes/TurbaKit_Client_Categories/_update_category/updates_a_category.json +1 -0
  37. data/spec/cassettes/TurbaKit_Client_Contents/_create_content/creates_a_content.json +1 -0
  38. data/spec/cassettes/TurbaKit_Client_Contents/_delete_content/deletes_a_content.json +1 -0
  39. data/spec/cassettes/TurbaKit_Client_Contents/_service_content/returns_a_content.json +1 -0
  40. data/spec/cassettes/TurbaKit_Client_Contents/_service_contents/lists_contents.json +1 -0
  41. data/spec/cassettes/TurbaKit_Client_Contents/_update_content/updates_a_content.json +1 -0
  42. data/spec/cassettes/TurbaKit_Client_Countries/_countries/returns_all_countries.json +1 -0
  43. data/spec/cassettes/TurbaKit_Client_Countries/_country/returns_a_country.json +1 -0
  44. data/spec/cassettes/TurbaKit_Client_Crowds/_create_crowd/creates_a_crowd.json +1 -0
  45. data/spec/cassettes/TurbaKit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +1 -0
  46. data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowd/returns_a_crowd.json +1 -0
  47. data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowds/lists_crowds.json +1 -0
  48. data/spec/cassettes/TurbaKit_Client_Crowds/_update_crowd/updates_a_crowd.json +1 -0
  49. data/spec/cassettes/TurbaKit_Client_Links/_create_link/creates_a_link.json +1 -0
  50. data/spec/cassettes/TurbaKit_Client_Links/_delete_link/deletes_a_link.json +1 -0
  51. data/spec/cassettes/TurbaKit_Client_Links/_service_link/returns_a_link.json +1 -0
  52. data/spec/cassettes/TurbaKit_Client_Links/_service_links/lists_links.json +1 -0
  53. data/spec/cassettes/TurbaKit_Client_Links/_update_link/updates_a_link.json +1 -0
  54. data/spec/cassettes/TurbaKit_Client_Notifications/_create_notification/creates_a_notification.json +1 -0
  55. data/spec/cassettes/TurbaKit_Client_Notifications/_delete_notification/deletes_a_notification.json +1 -0
  56. data/spec/cassettes/TurbaKit_Client_Notifications/_service_notification/returns_a_notification.json +1 -0
  57. data/spec/cassettes/TurbaKit_Client_Notifications/_service_notifications/lists_notifications.json +1 -0
  58. data/spec/cassettes/TurbaKit_Client_Notifications/_update_notification/updates_a_notification.json +1 -0
  59. data/spec/cassettes/TurbaKit_Client_Organismes/_create_organisme/creates_an_organisme.json +1 -0
  60. data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +1 -0
  61. data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +1 -0
  62. data/spec/cassettes/TurbaKit_Client_Organismes/_organisme/returns_a_organisme.json +1 -0
  63. data/spec/cassettes/TurbaKit_Client_Organismes/_organismes/handles_the_country_code_option.json +1 -0
  64. data/spec/cassettes/TurbaKit_Client_Organismes/_update_organisme/updates_an_organisme.json +1 -0
  65. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +1 -0
  66. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +1 -0
  67. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +1 -0
  68. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +1 -0
  69. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +1 -0
  70. data/spec/cassettes/TurbaKit_Client_Places/_create_place/creates_a_place.json +1 -0
  71. data/spec/cassettes/TurbaKit_Client_Places/_delete_place/deletes_a_place.json +1 -0
  72. data/spec/cassettes/TurbaKit_Client_Places/_service_place/returns_a_place.json +1 -0
  73. data/spec/cassettes/TurbaKit_Client_Places/_service_places/lists_places.json +1 -0
  74. data/spec/cassettes/TurbaKit_Client_Places/_update_place/updates_a_place.json +1 -0
  75. data/spec/cassettes/TurbaKit_Client_Services/_service/returns_a_service.json +1 -0
  76. data/spec/cassettes/TurbaKit_Client_Services/_services/handles_the_country_code_option.json +1 -0
  77. data/spec/cassettes/TurbaKit_Client_Tips/_create_tip/creates_a_tip.json +1 -0
  78. data/spec/cassettes/TurbaKit_Client_Tips/_delete_tip/deletes_a_tip.json +1 -0
  79. data/spec/cassettes/TurbaKit_Client_Tips/_service_tip/returns_a_tip.json +1 -0
  80. data/spec/cassettes/TurbaKit_Client_Tips/_service_tips/lists_tips.json +1 -0
  81. data/spec/cassettes/TurbaKit_Client_Tips/_update_tip/updates_a_tip.json +1 -0
  82. data/spec/cassettes/Turkit_Client_Categories/_categories/handles_the_country_code_option.json +1 -0
  83. data/spec/cassettes/Turkit_Client_Categories/_categories/returns_all_categories.json +1 -0
  84. data/spec/cassettes/Turkit_Client_Categories/_category/returns_a_category.json +1 -0
  85. data/spec/cassettes/Turkit_Client_Categories/_create_category/creates_a_category.json +1 -0
  86. data/spec/cassettes/Turkit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +1 -0
  87. data/spec/cassettes/Turkit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +1 -0
  88. data/spec/cassettes/Turkit_Client_Categories/_search_category/returns_a_list_of_categories.json +1 -0
  89. data/spec/cassettes/Turkit_Client_Categories/_update_category/updates_a_category.json +1 -0
  90. data/spec/cassettes/Turkit_Client_Contents/_create_content/creates_a_content.json +1 -0
  91. data/spec/cassettes/Turkit_Client_Contents/_delete_content/deletes_a_content.json +1 -0
  92. data/spec/cassettes/Turkit_Client_Contents/_service_content/returns_a_content.json +1 -0
  93. data/spec/cassettes/Turkit_Client_Contents/_service_contents/lists_contents.json +1 -0
  94. data/spec/cassettes/Turkit_Client_Contents/_update_content/updates_a_content.json +1 -0
  95. data/spec/cassettes/Turkit_Client_Countries/_countries/returns_all_countries.json +1 -0
  96. data/spec/cassettes/Turkit_Client_Countries/_country/returns_a_country.json +1 -0
  97. data/spec/cassettes/Turkit_Client_Crowds/_create_crowd/creates_a_crowd.json +1 -0
  98. data/spec/cassettes/Turkit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +1 -0
  99. data/spec/cassettes/Turkit_Client_Crowds/_service_crowd/returns_a_crowd.json +1 -0
  100. data/spec/cassettes/Turkit_Client_Crowds/_service_crowds/lists_crowds.json +1 -0
  101. data/spec/cassettes/Turkit_Client_Crowds/_update_crowd/updates_a_crowd.json +1 -0
  102. data/spec/cassettes/Turkit_Client_Links/_create_link/creates_a_link.json +1 -0
  103. data/spec/cassettes/Turkit_Client_Links/_delete_link/deletes_a_link.json +1 -0
  104. data/spec/cassettes/Turkit_Client_Links/_service_link/returns_a_link.json +1 -0
  105. data/spec/cassettes/Turkit_Client_Links/_service_links/lists_links.json +1 -0
  106. data/spec/cassettes/Turkit_Client_Links/_update_link/updates_a_link.json +1 -0
  107. data/spec/cassettes/Turkit_Client_Notifications/_create_notification/creates_a_notification.json +1 -0
  108. data/spec/cassettes/Turkit_Client_Notifications/_delete_notification/deletes_a_notification.json +1 -0
  109. data/spec/cassettes/Turkit_Client_Notifications/_service_notification/returns_a_notification.json +1 -0
  110. data/spec/cassettes/Turkit_Client_Notifications/_service_notifications/lists_notifications.json +1 -0
  111. data/spec/cassettes/Turkit_Client_Notifications/_update_notification/updates_a_notification.json +1 -0
  112. data/spec/cassettes/Turkit_Client_Organismes/_create_organisme/creates_an_organisme.json +1 -0
  113. data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +1 -0
  114. data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +1 -0
  115. data/spec/cassettes/Turkit_Client_Organismes/_organisme/returns_a_organisme.json +1 -0
  116. data/spec/cassettes/Turkit_Client_Organismes/_organismes/handles_the_country_code_option.json +1 -0
  117. data/spec/cassettes/Turkit_Client_Organismes/_organismes/returns_all_organismes.json +1 -0
  118. data/spec/cassettes/Turkit_Client_Organismes/_search_organisme/returns_a_list_of_organismes.json +1 -0
  119. data/spec/cassettes/Turkit_Client_Organismes/_update_organisme/updates_an_organisme.json +1 -0
  120. data/spec/cassettes/Turkit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +1 -0
  121. data/spec/cassettes/Turkit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +1 -0
  122. data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +1 -0
  123. data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +1 -0
  124. data/spec/cassettes/Turkit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +1 -0
  125. data/spec/cassettes/Turkit_Client_Places/_create_place/creates_a_place.json +1 -0
  126. data/spec/cassettes/Turkit_Client_Places/_delete_place/deletes_a_place.json +1 -0
  127. data/spec/cassettes/Turkit_Client_Places/_service_place/returns_a_place.json +1 -0
  128. data/spec/cassettes/Turkit_Client_Places/_service_places/lists_places.json +1 -0
  129. data/spec/cassettes/Turkit_Client_Places/_update_place/updates_a_place.json +1 -0
  130. data/spec/cassettes/Turkit_Client_Services/_search_service/returns_a_list_of_services.json +1 -0
  131. data/spec/cassettes/Turkit_Client_Services/_service/returns_a_service.json +1 -0
  132. data/spec/cassettes/Turkit_Client_Services/_services/handles_the_country_code_option.json +1 -0
  133. data/spec/cassettes/Turkit_Client_Services/_services/returns_all_services.json +1 -0
  134. data/spec/cassettes/Turkit_Client_Tips/_create_tip/creates_a_tip.json +1 -0
  135. data/spec/cassettes/Turkit_Client_Tips/_delete_tip/deletes_a_tip.json +1 -0
  136. data/spec/cassettes/Turkit_Client_Tips/_service_tip/returns_a_tip.json +1 -0
  137. data/spec/cassettes/Turkit_Client_Tips/_service_tips/lists_tips.json +1 -0
  138. data/spec/cassettes/Turkit_Client_Tips/_update_tip/updates_a_tip.json +1 -0
  139. data/spec/lib/categories_spec.rb +64 -0
  140. data/spec/lib/contents_spec.rb +47 -0
  141. data/spec/lib/countries_spec.rb +23 -0
  142. data/spec/lib/crowds_spec.rb +47 -0
  143. data/spec/lib/links_spec.rb +47 -0
  144. data/spec/lib/notifications_spec.rb +47 -0
  145. data/spec/lib/organismes_spec.rb +64 -0
  146. data/spec/lib/phonenumbers_spec.rb +47 -0
  147. data/spec/lib/place_spec.rb +47 -0
  148. data/spec/lib/services_spec.rb +64 -0
  149. data/spec/lib/tips_spec.rb +47 -0
  150. data/spec/spec_helper.rb +34 -0
  151. data/turba_kit.gemspec +24 -0
  152. metadata +356 -0
@@ -0,0 +1,47 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Links do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service_link", :vcr do
8
+ it "returns a link" do
9
+ link = @client.service_link('4E4BDA5B068E2C5B0E780100', '511E53C9E9B6CCBB89000FC6')
10
+ expect(link.text).to eq("Le guide J'aime Attendre des parcs de loisirs sans poireauter")
11
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E780100/links/511E53C9E9B6CCBB89000FC6")
12
+ end
13
+ end
14
+
15
+ describe ".service_links", :vcr do
16
+ it "lists links" do
17
+ links = @client.service_links('4E4BDA5B068E2C5B0E780100')
18
+ expect(links.count).to eq(2)
19
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E780100/links")
20
+ end
21
+ end
22
+
23
+ describe ".create_link", :vcr do
24
+ it "creates a link" do
25
+ link = @client.create_link('4E4BDA5B068E2C5B0E760100', 'Test link', 'http://www.google.fr')
26
+ expect(link.type).to eq('other')
27
+ assert_requested :post, turba_url("services/4E4BDA5B068E2C5B0E760100/links")
28
+ end
29
+ end
30
+
31
+ describe ".update_link", :vcr do
32
+ it "updates a link" do
33
+ link = @client.update_link('4E4BDA5B068E2C5B0E770100', '511E53BAE9B6CCBB89000F58', {text: 'Test'})
34
+ expect(link.text).to eq('Test')
35
+ assert_requested :put, turba_url("services/4E4BDA5B068E2C5B0E770100/links/511E53BAE9B6CCBB89000F58")
36
+ end
37
+ end
38
+
39
+ describe ".delete_link", :vcr do
40
+ it "deletes a link" do
41
+ link = @client.delete_link('4E4BDA5B068E2C5B0E770100', '515067CF9796B652A7000042')
42
+ expect(link).to eq(true)
43
+ assert_requested :delete, turba_url("services/4E4BDA5B068E2C5B0E770100/links/515067CF9796B652A7000042")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Notifications do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service_notification", :vcr do
8
+ it "returns a notification" do
9
+ notification = @client.service_notification('5118F4A0E9B6CCA1B20023BC', '511A09E5E9B6CC77BF0006F1')
10
+ expect(notification.type).to eq("notice")
11
+ assert_requested :get, turba_url("services/5118F4A0E9B6CCA1B20023BC/notifications/511A09E5E9B6CC77BF0006F1")
12
+ end
13
+ end
14
+
15
+ describe ".service_notifications", :vcr do
16
+ it "lists notifications" do
17
+ notifications = @client.service_notifications('5118F4A0E9B6CCA1B20023BC')
18
+ expect(notifications.count).to eq(1)
19
+ assert_requested :get, turba_url("services/5118F4A0E9B6CCA1B20023BC/notifications")
20
+ end
21
+ end
22
+
23
+ describe ".create_notification", :vcr do
24
+ it "creates a notification" do
25
+ notification = @client.create_notification('5118F48FE9B6CCA1B20023BB', 'Test notification')
26
+ expect(notification.text).to eq('Test notification')
27
+ assert_requested :post, turba_url("services/5118F48FE9B6CCA1B20023BB/notifications")
28
+ end
29
+ end
30
+
31
+ describe ".update_notification", :vcr do
32
+ it "updates a notification" do
33
+ notification = @client.update_notification('5118F4CCE9B6CCA1B2002D97', '511A09D2E9B6CC77BF0006EF', {text: 'Test'})
34
+ expect(notification.text).to eq('Test')
35
+ assert_requested :put, turba_url("services/5118F4CCE9B6CCA1B2002D97/notifications/511A09D2E9B6CC77BF0006EF")
36
+ end
37
+ end
38
+
39
+ describe ".delete_notification", :vcr do
40
+ it "deletes a notification" do
41
+ notification = @client.delete_notification('51431E97D74C000ADD000232', '514998376045FF634D000002')
42
+ expect(notification).to eq(true)
43
+ assert_requested :delete, turba_url("services/51431E97D74C000ADD000232/notifications/514998376045FF634D000002")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,64 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Organismes do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".organisme", :vcr do
8
+ it "returns a organisme" do
9
+ organisme = @client.organisme('52286624995fb7e10600004b')
10
+ expect(organisme.title).to eq('Fedex')
11
+ assert_requested :get, turba_url("organismes/52286624995fb7e10600004b")
12
+ end
13
+ end
14
+
15
+ describe ".search_organisme", :vcr do
16
+ it "returns a list of organismes" do
17
+ organismes = @client.search_organisme('lcl')
18
+ expect(organismes.count).to eq(2)
19
+ assert_requested :get, turba_url("organismes?q=lcl")
20
+ end
21
+ end
22
+
23
+ describe ".create_organisme", :vcr do
24
+ it "creates an organisme" do
25
+ @client.create_organisme("My test organisme", "my-test-organisme", "FR", "4E4BDA69068E2C5B0E980300")
26
+ assert_requested :post, turba_url("organismes")
27
+ end
28
+ end
29
+
30
+ describe ".organismes", :vcr do
31
+ it "returns all organismes" do
32
+ organismes = @client.organismes
33
+ expect(organismes.first.title).to eq("J'aime Attendre")
34
+ assert_requested :get, turba_url("organismes")
35
+ end
36
+
37
+ it "handles the country code option" do
38
+ organismes = @client.organismes(country_code: "BR")
39
+ expect(organismes.first.title).to eq('Museu do Meio Ambiente')
40
+ assert_requested :get, turba_url("organismes?country_code=BR")
41
+ end
42
+ end
43
+
44
+ describe ".delete_organisme", :vcr do
45
+ it "deletes a organisme and returns true" do
46
+ @client.create_organisme("Org test", "org-test", "FR", "4E4BDA69068E2C5B0E980300")
47
+ expect(@client.delete_organisme("fr-argent-org-test")).to eq(true)
48
+ assert_requested :delete, turba_url("organismes/fr-argent-org-test")
49
+ end
50
+
51
+ it "returns false if organisme doesn't exist" do
52
+ expect(@client.delete_organisme("fr-xxxxxx")).to eq(false)
53
+ assert_requested :delete, turba_url("organismes/fr-xxxxxx")
54
+ end
55
+ end
56
+
57
+ describe ".update_organisme", :vcr do
58
+ it "updates an organisme" do
59
+ @client.update_organisme("fr-argent-lcl", {title: "LCL"})
60
+ assert_requested :put, turba_url("organismes/fr-argent-lcl")
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Phonenumbers do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service_phonenumber", :vcr do
8
+ it "returns a phonenumber" do
9
+ phonenumber = @client.service_phonenumber('51f22a8b047d55c170000043', '51f27d4d047d55c17000007a')
10
+ expect(phonenumber.text).to eq('Recepção')
11
+ assert_requested :get, turba_url("services/51f22a8b047d55c170000043/phonenumbers/51f27d4d047d55c17000007a")
12
+ end
13
+ end
14
+
15
+ describe ".service_phonenumbers", :vcr do
16
+ it "lists phonenumbers" do
17
+ phonenumbers = @client.service_phonenumbers('4E4BDA5A068E2C5B0E510100')
18
+ expect(phonenumbers.count).to eq(1)
19
+ assert_requested :get, turba_url("services/4E4BDA5A068E2C5B0E510100/phonenumbers")
20
+ end
21
+ end
22
+
23
+ describe ".create_phonenumber", :vcr do
24
+ it "creates a phonenumber" do
25
+ phonenumber = @client.create_phonenumber('51f22a8b047d55c170000043', '1023', 'service client sfr', {surtaxable: false})
26
+ expect(phonenumber.surtaxable).to eq(false)
27
+ assert_requested :post, turba_url("services/51f22a8b047d55c170000043/phonenumbers")
28
+ end
29
+ end
30
+
31
+ describe ".update_phonenumber", :vcr do
32
+ it "updates a phonenumber" do
33
+ phonenumber = @client.update_phonenumber('51f22a8b047d55c170000043', '51F27D4D047D55C17000007A', {surtaxable: true, bypassable: true})
34
+ expect(phonenumber.surtaxable).to eq(true)
35
+ assert_requested :put, turba_url("services/51f22a8b047d55c170000043/phonenumbers/51F27D4D047D55C17000007A")
36
+ end
37
+ end
38
+
39
+ describe ".delete_phonenumber", :vcr do
40
+ it "deletes a phonenumber" do
41
+ phonenumber = @client.delete_phonenumber('4E4BDA5A068E2C5B0E530100', '4FDA5D46A13BCA74099C0000')
42
+ expect(phonenumber).to eq(true)
43
+ assert_requested :delete, turba_url("services/4E4BDA5A068E2C5B0E530100/phonenumbers/4FDA5D46A13BCA74099C0000")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Places do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service_place", :vcr do
8
+ it "returns a place" do
9
+ place = @client.service_place('4E4BDA5B068E2C5B0E7A0100', '50252CC2E9B6CC5237000143')
10
+ expect(place.text).to eq("Cité de l'Espace")
11
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E7A0100/places/50252CC2E9B6CC5237000143")
12
+ end
13
+ end
14
+
15
+ describe ".service_places", :vcr do
16
+ it "lists places" do
17
+ places = @client.service_places('4E4BDA5B068E2C5B0E7A0100')
18
+ expect(places.count).to eq(1)
19
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E7A0100/places")
20
+ end
21
+ end
22
+
23
+ describe ".create_place", :vcr do
24
+ it "creates a place" do
25
+ place = @client.create_place('4E4BDA5B068E2C5B0E7C0100', 'Test place', 'France', 'Lyon')
26
+ expect(place.city).to eq('Lyon')
27
+ assert_requested :post, turba_url("services/4E4BDA5B068E2C5B0E7C0100/places")
28
+ end
29
+ end
30
+
31
+ describe ".update_place", :vcr do
32
+ it "updates a place" do
33
+ place = @client.update_place('4E4BDA5B068E2C5B0E810100', '50252D7AE9B6CC523700014B', {text: 'Test'})
34
+ expect(place.text).to eq('Test')
35
+ assert_requested :put, turba_url("services/4E4BDA5B068E2C5B0E810100/places/50252D7AE9B6CC523700014B")
36
+ end
37
+ end
38
+
39
+ describe ".delete_place", :vcr do
40
+ it "deletes a place" do
41
+ place = @client.delete_place('4E4BDA5B068E2C5B0E820100', '50252DECE9B6CC5237000150')
42
+ expect(place).to eq(true)
43
+ assert_requested :delete, turba_url("services/4E4BDA5B068E2C5B0E820100/places/50252DECE9B6CC5237000150")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,64 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Services do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service", :vcr do
8
+ it "returns a service" do
9
+ service = @client.service('52d6602b30616400112e0000')
10
+ expect(service.title).to eq('Service client Afer')
11
+ assert_requested :get, turba_url("services/52d6602b30616400112e0000")
12
+ end
13
+ end
14
+
15
+ describe ".search_service", :vcr do
16
+ it "returns a list of services" do
17
+ services = @client.search_service('lcl')
18
+ expect(services.count).to eq(7)
19
+ assert_requested :get, turba_url("services?q=lcl")
20
+ end
21
+ end
22
+
23
+ # describe ".create_service", :vcr do
24
+ # it "creates an service" do
25
+ # @client.create_service("My test service", "my-test-service", "FR", "4E4BDA69068E2C5B0E980300")
26
+ # assert_requested :post, turba_url("services")
27
+ # end
28
+ # end
29
+
30
+ describe ".services", :vcr do
31
+ it "returns all services" do
32
+ services = @client.services
33
+ expect(services.first.title).to eq("Service client Virgin Mobile")
34
+ assert_requested :get, turba_url("services")
35
+ end
36
+
37
+ it "handles the country code option" do
38
+ services = @client.services(country_code: "BR")
39
+ expect(services.first.title).to eq('Museu do Meio Ambiente')
40
+ assert_requested :get, turba_url("services?country_code=BR")
41
+ end
42
+ end
43
+
44
+ # describe ".delete_service", :vcr do
45
+ # it "deletes a service and returns true" do
46
+ # @client.create_service("Org test", "org-test", "FR", "4E4BDA69068E2C5B0E980300")
47
+ # expect(@client.delete_service("fr-argent-org-test")).to eq(true)
48
+ # assert_requested :delete, turba_url("services/fr-argent-org-test")
49
+ # end
50
+
51
+ # it "returns false if service doesn't exist" do
52
+ # expect(@client.delete_service("fr-xxxxxx")).to eq(false)
53
+ # assert_requested :delete, turba_url("services/fr-xxxxxx")
54
+ # end
55
+ # end
56
+
57
+ # describe ".update_service", :vcr do
58
+ # it "updates an service" do
59
+ # @client.update_service("fr-argent-lcl", {title: "LCL"})
60
+ # assert_requested :put, turba_url("services/fr-argent-lcl")
61
+ # end
62
+ # end
63
+
64
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe TurbaKit::Client::Tips do
4
+
5
+ before { @client = TurbaKit.client }
6
+
7
+ describe ".service_tip", :vcr do
8
+ it "returns a tip" do
9
+ tip = @client.service_tip('4E4BDA5B068E2C5B0E780100', '5059BB5DE9B6CC6529000020')
10
+ expect(tip.title).to eq("Conseils de visite")
11
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E780100/tips/5059BB5DE9B6CC6529000020")
12
+ end
13
+ end
14
+
15
+ describe ".service_tips", :vcr do
16
+ it "lists tips" do
17
+ tips = @client.service_tips('4E4BDA5B068E2C5B0E780100')
18
+ expect(tips.count).to eq(1)
19
+ assert_requested :get, turba_url("services/4E4BDA5B068E2C5B0E780100/tips")
20
+ end
21
+ end
22
+
23
+ describe ".create_tip", :vcr do
24
+ it "creates a tip" do
25
+ tip = @client.create_tip('4E4BDA5B068E2C5B0E640100', 'Test tip', "tip 1\nTip 2")
26
+ expect(tip.title).to eq('Test tip')
27
+ assert_requested :post, turba_url("services/4E4BDA5B068E2C5B0E640100/tips")
28
+ end
29
+ end
30
+
31
+ describe ".update_tip", :vcr do
32
+ it "updates a tip" do
33
+ tip = @client.update_tip('4E4BDA5B068E2C5B0E680100', '5059C000E9B6CC6529000024', {title: 'Test'})
34
+ expect(tip.title).to eq('Test')
35
+ assert_requested :put, turba_url("services/4E4BDA5B068E2C5B0E680100/tips/5059C000E9B6CC6529000024")
36
+ end
37
+ end
38
+
39
+ describe ".delete_tip", :vcr do
40
+ it "deletes a tip" do
41
+ tip = @client.delete_tip('4E4BDA5B068E2C5B0E640100', '5045C4DDE9B6CC2451000047')
42
+ expect(tip).to eq(true)
43
+ assert_requested :delete, turba_url("services/4E4BDA5B068E2C5B0E640100/tips/5045C4DDE9B6CC2451000047")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../lib/turba_kit'
2
+
3
+ require 'rspec'
4
+ require 'webmock/rspec'
5
+ require 'vcr'
6
+ require 'turn'
7
+
8
+ API_VERSION = 'v2'
9
+
10
+ RSpec.configure do |config|
11
+ config.raise_errors_for_deprecations!
12
+ end
13
+
14
+ Turn.config do |c|
15
+ c.format = :outline
16
+ c.trace = true
17
+ c.natural = true
18
+ end
19
+
20
+ VCR.configure do |c|
21
+ c.configure_rspec_metadata!
22
+ c.default_cassette_options = {
23
+ serialize_with: :json,
24
+ preserve_exact_body_bytes: true,
25
+ decode_compressed_response: true,
26
+ record: :once
27
+ }
28
+ c.cassette_library_dir = 'spec/cassettes'
29
+ c.hook_into :webmock
30
+ end
31
+
32
+ def turba_url(url)
33
+ url =~ /^http/ ? url : "http://api.dev/#{API_VERSION}/#{url}"
34
+ end
data/turba_kit.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'turba_kit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.add_dependency 'sawyer', '~> 0.5.3'
8
+ spec.name = "turba_kit"
9
+ spec.version = TurbaKit::VERSION.dup
10
+ spec.authors = ["Joffrey JAFFEUX"]
11
+ spec.email = ["j.jaffeux@gmail.com"]
12
+ spec.description = %q{Write a gem description}
13
+ spec.summary = %q{Write a gem summary}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end