ruby-lokalise-api 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b5ad1966377b3613a7914324f5462329ff4f41b2367700d3614279a6214f45d
4
- data.tar.gz: 75855fa5e62fe199ea027afb0c6d8fd0a8efa6c08b7d6099a08963ccde631b75
3
+ metadata.gz: d80bce654f8a062530bb976701b4325642c2f9226d49b875ed9b611a0e8c7af8
4
+ data.tar.gz: 8d1a71d71f64fcd7fc4ea39d3f3501150f6f08ec809685d777343fc826250df1
5
5
  SHA512:
6
- metadata.gz: 7908537fe4e3f3fc750fcdac3ad3eadbd95e80a0a418c0dbc719990081d16c346a4ee428bebea4936ea6d1ae5219a2fd08dbae0b832002ee8b6bbb69f2914ce4
7
- data.tar.gz: 541a64ee224a4d86191e63968b78599da995e71443ac31cd076242ae2c5639365900a2a78adc741e2a74add6656443765e8f63e79746a3c89fcc177aec4ad1a5
6
+ metadata.gz: b3104ba420248487cd1baa2f4f310390b71a1e852002535ad2a2d85fcb61de9197804a05761b03d7a4fc38ddcbe3b12d3d2fce8c460666c02cda63162fb74269
7
+ data.tar.gz: c8c6a680b30f268dc0ec7823f6485dbe6211149177587f3e1ea108d81ad3d00a338a67a94e1959907b7ae9ea29526cc1840fd11172ad78fdafb35d28df1262d0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0 (19-Mar-19)
4
+
5
+ * Add support for `Order`, `TranslationProvider`, and `PaymentCard` endpoints
6
+
3
7
  ## 2.0.1 (21-Feb-19)
4
8
 
5
9
  * Bump dependencies
data/README.md CHANGED
@@ -18,6 +18,8 @@ Official opinionated Ruby interface for the [Lokalise API](https://lokalise.co/a
18
18
  + [Files](#files)
19
19
  + [Keys](#keys)
20
20
  + [Languages](#languages)
21
+ + [Orders](#orders)
22
+ + [Payment cards](#payment-cards)
21
23
  + [Projects](#projects)
22
24
  + [Screenshots](#screenshots)
23
25
  + [Snapshots](#snapshots)
@@ -25,6 +27,7 @@ Official opinionated Ruby interface for the [Lokalise API](https://lokalise.co/a
25
27
  + [Teams](#teams)
26
28
  + [Team users](#team-users)
27
29
  + [Translations](#translations)
30
+ + [Translation Providers](#translation-providers)
28
31
  * [Additional Info](#additional-info)
29
32
  + [Error handling](#error-handling)
30
33
  + [API Rate Limits](#api-rate-limits)
@@ -569,6 +572,119 @@ language = @client.language('project_id', 'lang_id')
569
572
  language.destroy
570
573
  ```
571
574
 
575
+ ### Orders
576
+
577
+ [Order attributes](https://lokalise.co/api2docs/curl/#object-orders)
578
+
579
+ #### Fetch order collection
580
+
581
+ [Doc](https://lokalise.co/api2docs/curl/#transition-list-all-orders-get)
582
+
583
+ ```ruby
584
+ @client.orders(team_id, params = {}) # Input:
585
+ ## team_id (integer, string, required)
586
+ ## params (hash)
587
+ ### :page and :limit
588
+ # Output:
589
+ ## Collection of orders for the given team
590
+ ```
591
+
592
+ #### Fetch a single order
593
+
594
+ [Doc](https://lokalise.co/api2docs/curl/#transition-retrieve-an-order-get)
595
+
596
+ ```ruby
597
+ @client.order(team_id, order_id) # Input:
598
+ ## team_id (string, integer, required)
599
+ ## order_id (string, required)
600
+ # Output:
601
+ ## A single order
602
+ ```
603
+
604
+ #### Create an order
605
+
606
+ [Doc](https://lokalise.co/api2docs/curl/#transition-create-an-order-post)
607
+
608
+ ```ruby
609
+ @client.create_order(team_id, params) # Input:
610
+ ## team_id (string, integer, required)
611
+ ## params (hash, required)
612
+ ### project_id (string, required)
613
+ ### card_id (integer, string, required) - card to process payment
614
+ ### briefing (string, required)
615
+ ### source_language_iso (string, required)
616
+ ### target_language_isos (array of strings, required)
617
+ ### keys (array of integers, required) - keys to include in the order
618
+ ### provider_slug (string, required)
619
+ ### translation_tier (integer, required)
620
+ ### dry_run (boolean) - return the response without actually placing an order. Useful for price estimation. Default is `false`
621
+ ### translation_style (string) - only for gengo provider. Available values are `formal`, `informal`, `business`, `friendly`. Defaults to `friendly`.
622
+ # Output:
623
+ ## A newly created order
624
+
625
+ ```
626
+
627
+ ### Payment cards
628
+
629
+ [Payment card attributes](https://lokalise.co/api2docs/ruby/#object-payment-cards)
630
+
631
+ #### Fetch payment card collection
632
+
633
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-cards-get)
634
+
635
+ ```ruby
636
+ @client.payment_cards(params = {}) # Input:
637
+ ## params (hash)
638
+ ### :page and :limit
639
+ # Output:
640
+ ## Collection of payment cards under the `payment_cards` attribute
641
+ ```
642
+
643
+ #### Fetch a single payment card
644
+
645
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-card-get)
646
+
647
+ ```ruby
648
+ @client.payment_card(card_id) # Input:
649
+ ## card_id (string, required)
650
+ # Output:
651
+ ## A single payment card
652
+ ```
653
+
654
+ #### Create a payment card
655
+
656
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-a-card-post)
657
+
658
+ ```ruby
659
+ @client.create_payment_card(params) # Input:
660
+ ## params (hash, required)
661
+ ### number (integer, string, required) - card number
662
+ ### cvc (integer, required) - 3-digit card CVV (CVC)
663
+ ### exp_month (integer, required) - card expiration month (1 - 12)
664
+ ### exp_year (integer, required) - card expiration year (for example, 2019)
665
+ # Output:
666
+ ## A newly created payment card
667
+
668
+ ```
669
+
670
+ #### Delete a payment card
671
+
672
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-card-delete)
673
+
674
+ ```ruby
675
+ @client.destroy_payment_card(card_id) # Input:
676
+ ## card_id (integer, string, required)
677
+ # Output:
678
+ ## Hash containing card id and `card_deleted => true` attribute
679
+ ```
680
+
681
+ Alternatively:
682
+
683
+ ```ruby
684
+ card = @client.payment_card('card_id')
685
+ card.destroy
686
+ ```
687
+
572
688
  ### Projects
573
689
 
574
690
  [Project attributes](https://lokalise.co/api2docs/php/#object-projects)
@@ -1059,6 +1175,35 @@ translation = @client.translation('project_id', 'translation_id')
1059
1175
  translation.update(params)
1060
1176
  ```
1061
1177
 
1178
+ ### Translation Providers
1179
+
1180
+ [Translation provider attributes](https://lokalise.co/api2docs/ruby/#object-translation-providers)
1181
+
1182
+ #### Fetch translations
1183
+
1184
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-providers-get)
1185
+
1186
+ ```ruby
1187
+ @client.translation_providers(team_id, params = {}) # Input:
1188
+ ## team_id (string, required)
1189
+ ## params (hash)
1190
+ ### :page and :limit
1191
+ # Output:
1192
+ ## Collection of providers for the team
1193
+ ```
1194
+
1195
+ #### Fetch a single translation
1196
+
1197
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-provider-get)
1198
+
1199
+ ```ruby
1200
+ @client.translation_provider(team_id, provider_id) # Input:
1201
+ ## team_id (string, required)
1202
+ ## provider_id (string, required)
1203
+ # Output:
1204
+ ## Single provider for the team
1205
+ ```
1206
+
1062
1207
  ## Additional Info
1063
1208
 
1064
1209
  ### Error handling
@@ -26,6 +26,9 @@ require 'ruby-lokalise-api/resources/key'
26
26
  require 'ruby-lokalise-api/resources/project_comment'
27
27
  require 'ruby-lokalise-api/resources/system_language'
28
28
  require 'ruby-lokalise-api/resources/team'
29
+ require 'ruby-lokalise-api/resources/order'
30
+ require 'ruby-lokalise-api/resources/payment_card'
31
+ require 'ruby-lokalise-api/resources/translation_provider'
29
32
 
30
33
  require 'ruby-lokalise-api/collections/base'
31
34
  require 'ruby-lokalise-api/collections/project'
@@ -42,6 +45,9 @@ require 'ruby-lokalise-api/collections/team_user'
42
45
  require 'ruby-lokalise-api/collections/task'
43
46
  require 'ruby-lokalise-api/collections/snapshot'
44
47
  require 'ruby-lokalise-api/collections/screenshot'
48
+ require 'ruby-lokalise-api/collections/order'
49
+ require 'ruby-lokalise-api/collections/payment_card'
50
+ require 'ruby-lokalise-api/collections/translation_provider'
45
51
 
46
52
  require 'ruby-lokalise-api/client'
47
53
 
@@ -10,6 +10,9 @@ require 'ruby-lokalise-api/rest/team_users'
10
10
  require 'ruby-lokalise-api/rest/tasks'
11
11
  require 'ruby-lokalise-api/rest/snapshots'
12
12
  require 'ruby-lokalise-api/rest/screenshots'
13
+ require 'ruby-lokalise-api/rest/orders'
14
+ require 'ruby-lokalise-api/rest/payment_cards'
15
+ require 'ruby-lokalise-api/rest/translation_providers'
13
16
 
14
17
  module Lokalise
15
18
  class Client
@@ -0,0 +1,11 @@
1
+ module Lokalise
2
+ module Collections
3
+ class Order < Base
4
+ class << self
5
+ def endpoint(team_id, *_args)
6
+ path_from teams: [team_id, 'orders']
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Lokalise
2
+ module Collections
3
+ class PaymentCard < Base
4
+ class << self
5
+ def endpoint(*_args)
6
+ path_from payment_cards: nil
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Lokalise
2
+ module Collections
3
+ class TranslationProvider < Base
4
+ class << self
5
+ def endpoint(team_id, *_args)
6
+ path_from teams: [team_id, 'translation_providers']
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -48,6 +48,31 @@
48
48
  "is_rtl",
49
49
  "plural_forms"
50
50
  ],
51
+ "order": [
52
+ "order_id",
53
+ "project_id",
54
+ "card_id",
55
+ "status",
56
+ "created_at",
57
+ "created_by",
58
+ "created_by_email",
59
+ "source_language_iso",
60
+ "target_language_isos",
61
+ "keys",
62
+ "source_words",
63
+ "provider_slug",
64
+ "translation_style",
65
+ "translation_tier",
66
+ "translation_tier_name",
67
+ "briefing",
68
+ "total"
69
+ ],
70
+ "payment_card": [
71
+ "card_id",
72
+ "last4",
73
+ "brand",
74
+ "created_at"
75
+ ],
51
76
  "project": [
52
77
  "project_id",
53
78
  "name",
@@ -123,5 +148,15 @@
123
148
  "is_fuzzy",
124
149
  "is_reviewed",
125
150
  "words"
151
+ ],
152
+ "translation_provider": [
153
+ "provider_id",
154
+ "name",
155
+ "slug",
156
+ "price_pair_min",
157
+ "website_url",
158
+ "description",
159
+ "tiers",
160
+ "pairs"
126
161
  ]
127
162
  }
@@ -102,8 +102,8 @@ module Lokalise
102
102
  # Some resources do not have ids at all
103
103
  return nil unless response['content'].key?(id_key) || response['content'].key?(data_key)
104
104
 
105
- # Content may be `{"project_id": '123', ...}` or {"snapshot": {"snapshot_id": '123', ...}}
106
- id = response['content'][id_key] || response['content'][data_key][id_key]
105
+ # ID of the resource
106
+ id = id_from response, id_key, data_key
107
107
 
108
108
  path = response['path'] || response['base_path']
109
109
  # If path already has id - just return it
@@ -113,6 +113,16 @@ module Lokalise
113
113
  path.remove_trailing_slash + "/#{id}"
114
114
  end
115
115
 
116
+ def id_from(response, id_key, data_key)
117
+ # Content may be `{"project_id": '123', ...}` or {"snapshot": {"snapshot_id": '123', ...}}
118
+ # Sometimes there is an `id_key` but it has a value of `null`
119
+ # (for example when we do not place the actual order but only check its price).
120
+ # Therefore we must explicitly check if the key is present
121
+ return response['content'][id_key] if response['content'].key?(id_key)
122
+
123
+ response['content'][data_key][id_key]
124
+ end
125
+
116
126
  # Store all resources attributes under the corresponding instance variables.
117
127
  # `ATTRIBUTES` is defined inside resource-specific classes
118
128
  def populate_attributes_for(content)
@@ -0,0 +1,12 @@
1
+ module Lokalise
2
+ module Resources
3
+ class Order < Base
4
+ class << self
5
+ def endpoint(team_id, order_id = nil)
6
+ path_from teams: team_id,
7
+ orders: order_id
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Lokalise
2
+ module Resources
3
+ class PaymentCard < Base
4
+ supports :destroy
5
+
6
+ class << self
7
+ def endpoint(card_id = nil)
8
+ path_from payment_cards: card_id
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Lokalise
2
+ module Resources
3
+ class TranslationProvider < Base
4
+ class << self
5
+ def endpoint(team_id, provider_id = nil)
6
+ path_from teams: team_id,
7
+ translation_providers: provider_id
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ module Lokalise
2
+ class Client
3
+ # Returns all orders for the given team
4
+ #
5
+ # @see https://lokalise.co/api2docs/curl/#transition-list-all-orders-get
6
+ # @return [Lokalise::Collection::Order<Lokalise::Resources::Order>]
7
+ # @param team_id [String]
8
+ # @param params [Hash]
9
+ def orders(team_id, params = {})
10
+ c_r Lokalise::Collections::Order, :all, team_id, params
11
+ end
12
+
13
+ # Returns a single order for the given team
14
+ #
15
+ # @see https://lokalise.co/api2docs/curl/#transition-retrieve-an-order-get
16
+ # @return [Lokalise::Resources::Order]
17
+ # @param team_id [String]
18
+ # @param order_id [String, Integer]
19
+ def order(team_id, order_id)
20
+ c_r Lokalise::Resources::Order, :find, [team_id, order_id]
21
+ end
22
+
23
+ # Creates an order for the given team
24
+ #
25
+ # @see https://lokalise.co/api2docs/curl/#transition-create-an-order-post
26
+ # @return [Lokalise::Resources::Order]
27
+ # @param team_id [String]
28
+ # @param params [Hash]
29
+ def create_order(team_id, params)
30
+ c_r Lokalise::Resources::Order, :create, team_id, params
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ module Lokalise
2
+ class Client
3
+ # Returns all payment cards available to the user authorized with the API token
4
+ #
5
+ # @see https://lokalise.co/api2docs/ruby/#transition-list-all-cards-get
6
+ # @return [Lokalise::Collection::PaymentCard<Lokalise::Resources::PaymentCard>]
7
+ # @param params [Hash]
8
+ def payment_cards(params = {})
9
+ c_r Lokalise::Collections::PaymentCard, :all, nil, params
10
+ end
11
+
12
+ # Returns a single payment card
13
+ #
14
+ # @see https://lokalise.co/api2docs/ruby/#transition-retrieve-a-card-get
15
+ # @return [Lokalise::Resources::PaymentCard]
16
+ # @param card_id [String, Integer]
17
+ def payment_card(card_id)
18
+ c_r Lokalise::Resources::PaymentCard, :find, card_id
19
+ end
20
+
21
+ # Creates a payment card
22
+ #
23
+ # @see https://lokalise.co/api2docs/curl/#transition-create-a-card-post
24
+ # @return [Lokalise::Resources::PaymentCard]
25
+ # @param params [Hash]
26
+ def create_payment_card(params)
27
+ c_r Lokalise::Resources::PaymentCard, :create, nil, params
28
+ end
29
+
30
+ # Deletes the payment card
31
+ #
32
+ # @see https://lokalise.co/api2docs/ruby/#transition-delete-a-card-delete
33
+ # @return [Hash]
34
+ # @param card_id [String, Integer]
35
+ def destroy_payment_card(card_id)
36
+ c_r Lokalise::Resources::PaymentCard, :destroy, card_id
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ module Lokalise
2
+ class Client
3
+ # Returns all translation providers for the given team
4
+ #
5
+ # @see https://lokalise.co/api2docs/ruby/#transition-list-all-providers-get
6
+ # @return [Lokalise::Collection::TranslationProvider<Lokalise::Resources::TranslationProvider>]
7
+ # @param team_id [String]
8
+ # @param params [Hash]
9
+ def translation_providers(team_id, params = {})
10
+ c_r Lokalise::Collections::TranslationProvider, :all, team_id, params
11
+ end
12
+
13
+ # Returns a single translation provider for the given team
14
+ #
15
+ # @see https://lokalise.co/api2docs/ruby/#transition-retrieve-a-provider-get
16
+ # @return [Lokalise::Resources::TranslationProvider]
17
+ # @param team_id [String]
18
+ # @param provider_id [String, Integer]
19
+ def translation_provider(team_id, provider_id)
20
+ c_r Lokalise::Resources::TranslationProvider, :find, [team_id, provider_id]
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Lokalise
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -0,0 +1,75 @@
1
+ RSpec.describe Lokalise::Client do
2
+ let(:team_id) { 176_692 }
3
+ let(:project_id) { '803826145ba90b42d5d860.46800099' }
4
+ let(:key_id) { 15_519_786 }
5
+ let(:order_id) { '201903198B2' }
6
+ let(:card_id) { 1774 }
7
+
8
+ describe '#orders' do
9
+ it 'should return all orders' do
10
+ orders = VCR.use_cassette('all_orders') do
11
+ test_client.orders team_id
12
+ end.collection
13
+
14
+ expect(orders.count).to eq(1)
15
+ expect(orders.first.order_id).to eq(order_id)
16
+ end
17
+
18
+ it 'should support pagination' do
19
+ orders = VCR.use_cassette('all_orders_pagination') do
20
+ test_client.orders team_id, limit: 1, page: 1
21
+ end
22
+
23
+ expect(orders.collection.count).to eq(1)
24
+ expect(orders.total_results).to eq(1)
25
+ expect(orders.total_pages).to eq(1)
26
+ expect(orders.results_per_page).to eq(1)
27
+ expect(orders.current_page).to eq(1)
28
+ end
29
+ end
30
+
31
+ specify '#order' do
32
+ order = VCR.use_cassette('order') do
33
+ test_client.order team_id, order_id
34
+ end
35
+
36
+ expect(order.order_id).to eq(order_id)
37
+ expect(order.project_id).to eq(project_id)
38
+ expect(order.card_id).to eq(card_id.to_s)
39
+ expect(order.status).to eq('in progress')
40
+ expect(order.created_at).to eq('2019-03-19 18:18:21 (Etc/UTC)')
41
+ expect(order.created_by).to eq(20_181)
42
+ expect(order.created_by_email).to eq('bodrovis@protonmail.com')
43
+ expect(order.source_language_iso).to eq('en')
44
+ expect(order.target_language_isos).to eq(%w[ru])
45
+ expect(order.keys).to eq([key_id])
46
+ expect(order.source_words['ru']).to eq(1)
47
+ expect(order.provider_slug).to eq('gengo')
48
+ expect(order.translation_style).to eq('friendly')
49
+ expect(order.translation_tier).to eq(1)
50
+ expect(order.translation_tier_name).to eq('Professional translator')
51
+ expect(order.briefing).to eq('Some briefing')
52
+ expect(order.total).to eq(0.07)
53
+ end
54
+
55
+ specify '#create_order' do
56
+ order = VCR.use_cassette('create_order') do
57
+ test_client.create_order team_id,
58
+ project_id: project_id,
59
+ card_id: card_id,
60
+ briefing: 'Some briefing',
61
+ source_language_iso: 'en',
62
+ target_language_isos: [
63
+ 'ru'
64
+ ],
65
+ keys: [
66
+ key_id
67
+ ],
68
+ provider_slug: 'gengo',
69
+ translation_tier: '1'
70
+ end
71
+
72
+ expect(order.order_id).to eq(order_id)
73
+ expect(order.status).to eq('in progress')
74
+ end
75
+ end
@@ -0,0 +1,76 @@
1
+ RSpec.describe Lokalise::Client do
2
+ let(:card_id) { 1773 }
3
+
4
+ describe '#payment_cards' do
5
+ it 'should return all payment cards' do
6
+ cards = VCR.use_cassette('all_payment_cards') do
7
+ test_client.payment_cards
8
+ end.collection
9
+
10
+ card = cards.first
11
+ expect(card.card_id).to eq(1774)
12
+ expect(card.last4).to eq('0358')
13
+ end
14
+
15
+ it 'should support pagination' do
16
+ cards = VCR.use_cassette('all_payment_cards_pagination') do
17
+ test_client.payment_cards limit: 1, page: 1
18
+ end
19
+
20
+ expect(cards.collection.count).to eq(1)
21
+ expect(cards.total_results).to eq(1)
22
+ expect(cards.total_pages).to eq(1)
23
+ expect(cards.results_per_page).to eq(1)
24
+ expect(cards.current_page).to eq(1)
25
+
26
+ expect(cards.next_page?).to eq(false)
27
+ expect(cards.last_page?).to eq(true)
28
+ expect(cards.prev_page?).to eq(false)
29
+ expect(cards.first_page?).to eq(true)
30
+ end
31
+ end
32
+
33
+ specify '#create_payment_card' do
34
+ card = VCR.use_cassette('new_payment_card') do
35
+ test_client.create_payment_card number: '4242424242424242',
36
+ "cvc": '123',
37
+ "exp_month": 1,
38
+ "exp_year": 2030
39
+ end
40
+
41
+ expect(card.card_id).to eq(card_id)
42
+ expect(card.last4).to eq('4242')
43
+ end
44
+
45
+ specify '#payment_card' do
46
+ card = VCR.use_cassette('payment_card') do
47
+ test_client.payment_card card_id
48
+ end
49
+
50
+ expect(card.card_id).to eq(card_id)
51
+ expect(card.brand).to eq('Visa')
52
+ expect(card.last4).to eq('4242')
53
+ expect(card.created_at).to eq('2019-03-19 17:01:22 (Etc/UTC)')
54
+ end
55
+
56
+ specify '#destroy_payment_card' do
57
+ result = VCR.use_cassette('destroy_payment_card') do
58
+ test_client.destroy_payment_card card_id
59
+ end
60
+
61
+ expect(result['card_deleted']).to eq(true)
62
+ expect(result['card_id']).to eq(card_id)
63
+ end
64
+
65
+ it 'should support chained destroy' do
66
+ card = VCR.use_cassette('payment_card') do
67
+ test_client.payment_card card_id
68
+ end
69
+ result = VCR.use_cassette('destroy_payment_card') do
70
+ card.destroy
71
+ end
72
+
73
+ expect(result['card_deleted']).to eq(true)
74
+ expect(result['card_id']).to eq(card_id)
75
+ end
76
+ end
@@ -0,0 +1,41 @@
1
+ RSpec.describe Lokalise::Client do
2
+ let(:team_id) { 176_692 }
3
+
4
+ describe '#translation_providers' do
5
+ it 'should return all providers' do
6
+ providers = VCR.use_cassette('all_translation_providers') do
7
+ test_client.translation_providers team_id
8
+ end.collection
9
+
10
+ expect(providers.count).to eq(2)
11
+ expect(providers.first.slug).to eq('gengo')
12
+ end
13
+
14
+ it 'should support pagination' do
15
+ providers = VCR.use_cassette('all_translation_providers_pagination') do
16
+ test_client.translation_providers team_id, limit: 2, page: 1
17
+ end
18
+
19
+ expect(providers.collection.count).to eq(1)
20
+ expect(providers.total_results).to eq(3)
21
+ expect(providers.total_pages).to eq(2)
22
+ expect(providers.results_per_page).to eq(2)
23
+ expect(providers.current_page).to eq(1)
24
+ end
25
+ end
26
+
27
+ specify '#translation_provider' do
28
+ provider = VCR.use_cassette('translation_provider') do
29
+ test_client.translation_provider team_id, 1
30
+ end
31
+
32
+ expect(provider.provider_id).to eq(1)
33
+ expect(provider.name).to eq('Gengo')
34
+ expect(provider.slug).to eq('gengo')
35
+ expect(provider.price_pair_min).to eq('0.00')
36
+ expect(provider.website_url).to eq('https://gengo.com')
37
+ expect(provider.description.start_with?('At')).to eq(true)
38
+ expect(provider.tiers.first['title']).to eq('Native speaker')
39
+ expect(provider.pairs.first['price_per_word']).to eq('0.05')
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-21 00:00:00.000000000 Z
11
+ date: 2019-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -161,6 +161,8 @@ files:
161
161
  - lib/ruby-lokalise-api/collections/file.rb
162
162
  - lib/ruby-lokalise-api/collections/key.rb
163
163
  - lib/ruby-lokalise-api/collections/key_comment.rb
164
+ - lib/ruby-lokalise-api/collections/order.rb
165
+ - lib/ruby-lokalise-api/collections/payment_card.rb
164
166
  - lib/ruby-lokalise-api/collections/project.rb
165
167
  - lib/ruby-lokalise-api/collections/project_comment.rb
166
168
  - lib/ruby-lokalise-api/collections/project_language.rb
@@ -171,6 +173,7 @@ files:
171
173
  - lib/ruby-lokalise-api/collections/team.rb
172
174
  - lib/ruby-lokalise-api/collections/team_user.rb
173
175
  - lib/ruby-lokalise-api/collections/translation.rb
176
+ - lib/ruby-lokalise-api/collections/translation_provider.rb
174
177
  - lib/ruby-lokalise-api/connection.rb
175
178
  - lib/ruby-lokalise-api/data/attributes.json
176
179
  - lib/ruby-lokalise-api/error.rb
@@ -180,6 +183,8 @@ files:
180
183
  - lib/ruby-lokalise-api/resources/file.rb
181
184
  - lib/ruby-lokalise-api/resources/key.rb
182
185
  - lib/ruby-lokalise-api/resources/key_comment.rb
186
+ - lib/ruby-lokalise-api/resources/order.rb
187
+ - lib/ruby-lokalise-api/resources/payment_card.rb
183
188
  - lib/ruby-lokalise-api/resources/project.rb
184
189
  - lib/ruby-lokalise-api/resources/project_comment.rb
185
190
  - lib/ruby-lokalise-api/resources/project_language.rb
@@ -190,17 +195,21 @@ files:
190
195
  - lib/ruby-lokalise-api/resources/team.rb
191
196
  - lib/ruby-lokalise-api/resources/team_user.rb
192
197
  - lib/ruby-lokalise-api/resources/translation.rb
198
+ - lib/ruby-lokalise-api/resources/translation_provider.rb
193
199
  - lib/ruby-lokalise-api/rest/comments.rb
194
200
  - lib/ruby-lokalise-api/rest/contributors.rb
195
201
  - lib/ruby-lokalise-api/rest/files.rb
196
202
  - lib/ruby-lokalise-api/rest/keys.rb
197
203
  - lib/ruby-lokalise-api/rest/languages.rb
204
+ - lib/ruby-lokalise-api/rest/orders.rb
205
+ - lib/ruby-lokalise-api/rest/payment_cards.rb
198
206
  - lib/ruby-lokalise-api/rest/projects.rb
199
207
  - lib/ruby-lokalise-api/rest/screenshots.rb
200
208
  - lib/ruby-lokalise-api/rest/snapshots.rb
201
209
  - lib/ruby-lokalise-api/rest/tasks.rb
202
210
  - lib/ruby-lokalise-api/rest/team_users.rb
203
211
  - lib/ruby-lokalise-api/rest/teams.rb
212
+ - lib/ruby-lokalise-api/rest/translation_providers.rb
204
213
  - lib/ruby-lokalise-api/rest/translations.rb
205
214
  - lib/ruby-lokalise-api/utils/attribute_helpers.rb
206
215
  - lib/ruby-lokalise-api/utils/endpoint_helpers.rb
@@ -213,12 +222,15 @@ files:
213
222
  - spec/lib/ruby-lokalise-api/rest/files_spec.rb
214
223
  - spec/lib/ruby-lokalise-api/rest/keys_spec.rb
215
224
  - spec/lib/ruby-lokalise-api/rest/languages_spec.rb
225
+ - spec/lib/ruby-lokalise-api/rest/orders_spec.rb
226
+ - spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb
216
227
  - spec/lib/ruby-lokalise-api/rest/projects_spec.rb
217
228
  - spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb
218
229
  - spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb
219
230
  - spec/lib/ruby-lokalise-api/rest/tasks_spec.rb
220
231
  - spec/lib/ruby-lokalise-api/rest/team_users_spec.rb
221
232
  - spec/lib/ruby-lokalise-api/rest/teams_spec.rb
233
+ - spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb
222
234
  - spec/lib/ruby-lokalise-api/rest/translations_spec.rb
223
235
  - spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb
224
236
  - spec/lib/ruby-lokalise-api_spec.rb
@@ -244,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
256
  - !ruby/object:Gem::Version
245
257
  version: '0'
246
258
  requirements: []
247
- rubygems_version: 3.0.2
259
+ rubygems_version: 3.0.3
248
260
  signing_key:
249
261
  specification_version: 4
250
262
  summary: Ruby interface to the Lokalise API
@@ -255,6 +267,8 @@ test_files:
255
267
  - spec/lib/ruby-lokalise-api/rest/files_spec.rb
256
268
  - spec/lib/ruby-lokalise-api/rest/keys_spec.rb
257
269
  - spec/lib/ruby-lokalise-api/rest/languages_spec.rb
270
+ - spec/lib/ruby-lokalise-api/rest/orders_spec.rb
271
+ - spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb
258
272
  - spec/lib/ruby-lokalise-api/rest/projects_spec.rb
259
273
  - spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb
260
274
  - spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb
@@ -262,6 +276,7 @@ test_files:
262
276
  - spec/lib/ruby-lokalise-api/rest/teams_spec.rb
263
277
  - spec/lib/ruby-lokalise-api/rest/team_users_spec.rb
264
278
  - spec/lib/ruby-lokalise-api/rest/translations_spec.rb
279
+ - spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb
265
280
  - spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb
266
281
  - spec/lib/ruby-lokalise-api_spec.rb
267
282
  - spec/spec_helper.rb